Skip to content

Commit

Permalink
add exception parameter to the log...() method calls
Browse files Browse the repository at this point in the history
replace string concatenation with throwable parameter
see wso2#1974
  • Loading branch information
nitram509 committed Oct 9, 2020
1 parent 15d1f83 commit c4ece01
Show file tree
Hide file tree
Showing 16 changed files with 47 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public static IdentityProvider build(OMElement identityProviderOM) {
} catch (IdentityApplicationManagementException e) {
log.error("Error while building provisioningConnectorConfig for IDP " + identityProvider
.getIdentityProviderName() + ". Cause : " + e.getMessage() + ". Building rest of the " +
"IDP configs");
"IDP configs", e);
}
if (proConConfig != null) {
provisioningConnectorConfigsArrList.add(proConConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1865,7 +1865,7 @@ public static String getMultiAttributeSeparator() {
} catch (UserStoreException e) {
log.warn("Error while retrieving MultiAttributeSeparator from UserRealm.");
if (log.isDebugEnabled()) {
log.debug("Error while retrieving MultiAttributeSeparator from UserRealm." + e);
log.debug("Error while retrieving MultiAttributeSeparator from UserRealm.", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
import org.osgi.service.component.annotations.ReferencePolicy;

@Component(
name = "org.wso2.carbon.identity.thrift.authentication.internal.ThriftAuthenticationServiceComponent",
name = "org.wso2.carbon.identity.thrift.authentication.internal.ThriftAuthenticationServiceComponent",
immediate = true)
public class ThriftAuthenticationServiceComponent {

Expand Down Expand Up @@ -130,10 +130,10 @@ public static void setRealmServiceInstance(RealmService realmServiceInstance) {
}

@Reference(
name = "http.service",
service = org.osgi.service.http.HttpService.class,
cardinality = ReferenceCardinality.MANDATORY,
policy = ReferencePolicy.DYNAMIC,
name = "http.service",
service = org.osgi.service.http.HttpService.class,
cardinality = ReferenceCardinality.MANDATORY,
policy = ReferencePolicy.DYNAMIC,
unbind = "unsetHttpService")
protected void setHttpService(HttpService httpService) {
setHttpServiceInstance(httpService);
Expand All @@ -144,10 +144,10 @@ protected void unsetHttpService(HttpService httpService) {
}

@Reference(
name = "org.wso2.carbon.user.core",
service = org.wso2.carbon.user.core.service.RealmService.class,
cardinality = ReferenceCardinality.MANDATORY,
policy = ReferencePolicy.DYNAMIC,
name = "org.wso2.carbon.user.core",
service = org.wso2.carbon.user.core.service.RealmService.class,
cardinality = ReferenceCardinality.MANDATORY,
policy = ReferencePolicy.DYNAMIC,
unbind = "unsetRealmService")
protected void setRealmService(RealmService realmService) {
setRealmServiceInstance(realmService);
Expand All @@ -158,10 +158,10 @@ protected void unsetRealmService(RealmService realmService) {
}

@Reference(
name = "configuration.context",
service = org.wso2.carbon.utils.ConfigurationContextService.class,
cardinality = ReferenceCardinality.MANDATORY,
policy = ReferencePolicy.DYNAMIC,
name = "configuration.context",
service = org.wso2.carbon.utils.ConfigurationContextService.class,
cardinality = ReferenceCardinality.MANDATORY,
policy = ReferencePolicy.DYNAMIC,
unbind = "unsetConfigurationContext")
protected void setConfigurationContext(ConfigurationContextService configurationContext) {
this.configurationContext = configurationContext;
Expand All @@ -184,9 +184,9 @@ private void startThriftHttpAuthenticatorService(ThriftAuthenticatorService thri
TCompactProtocol.Factory outProtFactory = new TCompactProtocol.Factory();
getHttpServiceInstance().registerServlet("/thriftAuthenticator", new AuthenticatorServlet(authServiceProcessor, inProtFactory, outProtFactory), new Hashtable(), getHttpServiceInstance().createDefaultHttpContext());
} catch (ServletException e) {
log.error("Unable to start Thrift Authenticator Service." + e);
log.error("Unable to start Thrift Authenticator Service.", e);
} catch (NamespaceException e) {
log.error("Unable to start Thrift Authenticator Service" + e);
log.error("Unable to start Thrift Authenticator Service", e);
}
}

Expand Down Expand Up @@ -237,7 +237,7 @@ private void startThriftTcpAuthenticatorService(ThriftAuthenticatorService thrif
clientTimeout = Integer.parseInt(clientTimeoutElement.getText());
} catch (Throwable e) {
String msg = "Error, in Thrift Auth Client Timeout, hence using the default timeout: " + ThriftAuthenticationConstants.DEFAULT_CLIENT_TIMEOUT + "ms";
log.error(msg + e);
log.error(msg, e);
clientTimeout = ThriftAuthenticationConstants.DEFAULT_CLIENT_TIMEOUT;
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public static boolean validatePolicy(PolicyDTO policy) {
log.error("Invalid Namespace in policy");
}
} catch (SAXException e) {
log.error("XACML policy is not valid according to the schema :" + e.getMessage());
log.error("XACML policy is not valid according to the schema :" + e.getMessage(), e);
} catch (IOException e) {
//ignore
} catch (ParserConfigurationException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,29 +212,29 @@ public EvaluationResult findAttribute(URI attributeType, URI attributeId, String
}
}
} catch (ParsingException e) {
log.error("Error while parsing attribute values from EvaluationCtx : " + e);
log.error("Error while parsing attribute values from EvaluationCtx : ", e);
ArrayList<String> code = new ArrayList<String>();
code.add(Status.STATUS_MISSING_ATTRIBUTE);
Status status = new Status(code,
"Error while parsing attribute values from EvaluationCtx : " + e.getMessage());
return new EvaluationResult(status);
} catch (ParseException e) {
e.printStackTrace();
log.error("Error while parsing attribute values from EvaluationCtx : " + e);
log.error("Error while parsing attribute values from EvaluationCtx : ", e);
ArrayList<String> code = new ArrayList<String>();
code.add(Status.STATUS_MISSING_ATTRIBUTE);
Status status = new Status(code,
"Error while parsing attribute values from EvaluationCtx : " + e.getMessage());
return new EvaluationResult(status);
} catch (URISyntaxException e) {
log.error("Error while parsing attribute values from EvaluationCtx : " + e);
log.error("Error while parsing attribute values from EvaluationCtx : ", e);
ArrayList<String> code = new ArrayList<String>();
code.add(Status.STATUS_MISSING_ATTRIBUTE);
Status status = new Status(code,
"Error while parsing attribute values from EvaluationCtx :" + e.getMessage());
return new EvaluationResult(status);
} catch (Exception e) {
log.error("Error while retrieving attribute values from PIP attribute finder : " + e);
log.error("Error while retrieving attribute values from PIP attribute finder : ", e);
ArrayList<String> code = new ArrayList<String>();
code.add(Status.STATUS_MISSING_ATTRIBUTE);
Status status = new Status(code, "Error while retrieving attribute values from PIP"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private void evaluateScript(FunctionLibrary functionLibrary) throws FunctionLibr
engine.eval(code);
} catch (ScriptException e) {
log.error("Script library script of " + functionLibrary.getFunctionLibraryName() +
" contains errors." + e);
" contains errors.", e);
throw FunctionLibraryExceptionManagementUtil.handleClientException(
FunctionLibraryManagementConstants.ErrorMessage.ERROR_CODE_VALIDATE_SCRIPT_LIBRARY_SCRIPT,
functionLibrary.getFunctionLibraryName(), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private void evaluateScript(FunctionLibrary functionLibrary) throws FunctionLibr
engine.eval(code);
} catch (ScriptException e) {
log.error("Script library script of " + functionLibrary.getFunctionLibraryName() +
" contains errors." + e);
" contains errors.", e);
throw FunctionLibraryExceptionManagementUtil.handleClientException(
FunctionLibraryManagementConstants.ErrorMessage.ERROR_CODE_VALIDATE_SCRIPT_LIBRARY_SCRIPT,
functionLibrary.getFunctionLibraryName(), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static <T extends IdentityException> T error(Class<T> exceptionClass, Str
try {
exception = exceptionClass.getConstructor(String.class, String.class).newInstance(errorCode, message);
} catch (Exception e) {
throw new IdentityRuntimeException("Invalid Exception Type, " + e.getMessage());
throw new IdentityRuntimeException("Invalid Exception Type, " + e.getMessage(), e);
}
return exception;
}
Expand All @@ -87,7 +87,7 @@ public static <T extends IdentityException> T error(Class<T> exceptionClass, Str
try {
exception = exceptionClass.getConstructor(String.class, Throwable.class).newInstance(message, cause);
} catch (Exception e) {
throw new IdentityRuntimeException("Invalid Exception Type, " + e.getMessage());
throw new IdentityRuntimeException("Invalid Exception Type, " + e.getMessage(), e);
}
return exception;
}
Expand All @@ -99,7 +99,7 @@ public static <T extends IdentityException> T error(Class<T> exceptionClass, Str
exception = exceptionClass.getConstructor(String.class, String.class, Throwable.class).
newInstance(errorCode, message, cause);
} catch (Exception e) {
throw new IdentityRuntimeException("Invalid Exception Type, " + e.getMessage());
throw new IdentityRuntimeException("Invalid Exception Type, " + e.getMessage(), e);
}
return exception;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static <T extends IdentityRuntimeException> T error(Class<T> exceptionCla
try {
exception = exceptionClass.getConstructor(String.class).newInstance(message);
} catch (Exception e) {
throw new IdentityRuntimeException("Invalid Exception Type, " + e.getMessage());
throw new IdentityRuntimeException("Invalid Exception Type, " + e.getMessage(), e);
}
return exception;
}
Expand All @@ -83,7 +83,7 @@ public static <T extends IdentityRuntimeException> T error(Class<T> exceptionCla
try {
exception = exceptionClass.getConstructor(String.class, String.class).newInstance(errorCode, message);
} catch (Exception e) {
throw new IdentityRuntimeException("Invalid Exception Type, " + e.getMessage());
throw new IdentityRuntimeException("Invalid Exception Type, " + e.getMessage(), e);
}
return exception;
}
Expand All @@ -93,7 +93,7 @@ public static <T extends IdentityRuntimeException> T error(Class<T> exceptionCla
try {
exception = exceptionClass.getConstructor(String.class, Throwable.class).newInstance(message, cause);
} catch (Exception e) {
throw new IdentityRuntimeException("Invalid Exception Type, " + e.getMessage());
throw new IdentityRuntimeException("Invalid Exception Type, " + e.getMessage(), e);
}
return exception;
}
Expand All @@ -105,7 +105,7 @@ public static <T extends IdentityRuntimeException> T error(Class<T> exceptionCla
exception = exceptionClass.getConstructor(String.class, String.class, Throwable.class).
newInstance(errorCode, message, cause);
} catch (Exception e) {
throw new IdentityRuntimeException("Invalid Exception Type, " + e.getMessage());
throw new IdentityRuntimeException("Invalid Exception Type, " + e.getMessage(), e);
}
return exception;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*
* Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
Expand Down Expand Up @@ -332,7 +332,7 @@ public static String getHMAC(String secretKey, String baseString) throws Signatu
byte[] rawHmac = mac.doFinal(baseString.getBytes());
return Base64.getEncoder().encodeToString(rawHmac);
} catch (Exception e) {
throw new SignatureException("Failed to generate HMAC : " + e.getMessage());
throw new SignatureException("Failed to generate HMAC : " + e.getMessage(), e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private void deleteOldResourcesIfFound() {
collection = (Collection) registry.get(secretKeyPath.toLowerCase());
} catch (RegistryException e) {
log.error(
"Error while deleting the old confirmation code. Unable to find data collection in registry." + e);
"Error while deleting the old confirmation code. Unable to find data collection in registry.", e);
}

//Introduced property to fix resource not being introduced deleted when special characters are present.
Expand Down Expand Up @@ -129,7 +129,7 @@ public int compare(Resource r1, Resource r2) {
}
}
} catch (RegistryException e) {
log.error("Error while deleting the old confirmation code \n" + e);
log.error("Error while deleting the old confirmation code", e);
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private WorkflowWizard getWorkflow(org.wso2.carbon.identity.workflow.mgt.bean.Wo
} catch (InternalWorkflowException e) {
String errorMsg =
"Error occurred while reading workflow object details for given workflow id, " + e.getMessage();
log.error(errorMsg);
log.error(errorMsg, e);
throw new WorkflowException(errorMsg, e);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public boolean isAssociated() throws WorkflowException{
eventEngaged = WorkflowServiceDataHolder.getInstance().getWorkflowService().isEventAssociated(getEventId());
} catch (InternalWorkflowException e) {
String errorMsg = "Error occurred while checking any association for this event, " + e.getMessage() ;
log.error(errorMsg);
log.error(errorMsg, e);
throw new WorkflowException(errorMsg,e);
}
return eventEngaged ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public AbstractTemplate(String metaDataXML) throws WorkflowRuntimeException {
this.parametersMetaData = this.metaData.getTemplate().getParametersMetaData();
} catch (JAXBException e) {
String errorMsg = "Error occured while converting template parameter data to object : " + e.getMessage();
log.error(errorMsg);
log.error(errorMsg, e);
throw new WorkflowRuntimeException(errorMsg, e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public static String readFileFromResource(InputStream resourceAsStream) throws U

} catch (IOException e) {
String errorMsg = "Error occurred while reading file from class path, " + e.getMessage();
log.error(errorMsg);
log.error(errorMsg, e);
throw new WorkflowRuntimeException(errorMsg, e);
}
return content;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public AbstractWorkflow(Class<? extends TemplateInitializer> templateInitializer
this.parametersMetaData = this.metaData.getWorkflowImpl().getParametersMetaData();
} catch (JAXBException e) {
String errorMsg = "Error occurred while converting workflow parameter data to object : " + e.getMessage();
log.error(errorMsg);
log.error(errorMsg, e);
throw new WorkflowRuntimeException(errorMsg, e);
}
}
Expand Down Expand Up @@ -166,11 +166,11 @@ public WorkFlowExecutor getWorkFlowExecutor() {
workFlowExecutor = workFlowExecutorClass.newInstance();
} catch (InstantiationException e) {
String errorMsg = "Error occurred while initializing WorkFlowExecutor : " + e.getMessage();
log.error(errorMsg);
log.error(errorMsg, e);
throw new WorkflowRuntimeException(errorMsg, e);
} catch (IllegalAccessException e) {
String errorMsg = "Error occurred while initializing WorkFlowExecutor : " + e.getMessage();
log.error(errorMsg);
log.error(errorMsg, e);
throw new WorkflowRuntimeException(errorMsg, e);
}
return workFlowExecutor;
Expand All @@ -184,11 +184,11 @@ public TemplateInitializer getTemplateInitializer() throws WorkflowRuntimeExcept
templateInitializer = templateInitializerClass.newInstance();
} catch (InstantiationException e) {
String errorMsg = "Error occurred while initializing TemplateInitializer : " + e.getMessage();
log.error(errorMsg);
log.error(errorMsg, e);
throw new WorkflowRuntimeException(errorMsg, e);
} catch (IllegalAccessException e) {
String errorMsg = "Error occurred while initializing TemplateInitializer : " + e.getMessage();
log.error(errorMsg);
log.error(errorMsg, e);
throw new WorkflowRuntimeException(errorMsg, e);
}
return templateInitializer;
Expand Down

0 comments on commit c4ece01

Please sign in to comment.