Skip to content

Commit 0b5d004

Browse files
committed
GEODE-10231 : Add configuration for suppressing FunctionException logging
- pmd fix - logger format fix
1 parent b457f15 commit 0b5d004

File tree

9 files changed

+31
-19
lines changed

9 files changed

+31
-19
lines changed

geode-core/src/main/java/org/apache/geode/internal/cache/execute/AbstractExecution.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
import org.apache.geode.InternalGemFireException;
2929
import org.apache.geode.SystemFailure;
30+
import org.apache.geode.annotations.Immutable;
3031
import org.apache.geode.annotations.internal.MakeNotStatic;
3132
import org.apache.geode.cache.LowMemoryException;
3233
import org.apache.geode.cache.TransactionException;
@@ -57,7 +58,8 @@
5758
*/
5859
public abstract class AbstractExecution implements InternalExecution {
5960
private static final Logger logger = LogService.getLogger();
60-
private static final Marker FUNCTION_EXCEPTION_MARKER =
61+
@Immutable
62+
private static final Marker functionExceptionMarker =
6163
MarkerManager.getMarker("FUNCTION_EXCEPTION_MARKER");
6264

6365
public static final int DEFAULT_CLIENT_FUNCTION_TIMEOUT = 0;
@@ -508,7 +510,7 @@ private void handleException(Throwable functionException, final Function fn,
508510
((InternalResultSender) sender).setException(functionException);
509511
}
510512
} else {
511-
logger.warn(functionException instanceof FunctionException ? FUNCTION_EXCEPTION_MARKER : null,
513+
logger.warn(functionException instanceof FunctionException ? functionExceptionMarker : null,
512514
"Exception occurred on local node while executing Function:",
513515
functionException);
514516
}

geode-core/src/main/java/org/apache/geode/internal/cache/execute/DistributedRegionFunctionResultSender.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.apache.logging.log4j.Marker;
1919
import org.apache.logging.log4j.MarkerManager;
2020

21+
import org.apache.geode.annotations.Immutable;
2122
import org.apache.geode.cache.execute.Function;
2223
import org.apache.geode.cache.execute.FunctionException;
2324
import org.apache.geode.cache.execute.ResultCollector;
@@ -31,7 +32,8 @@
3132
public class DistributedRegionFunctionResultSender implements InternalResultSender {
3233

3334
private static final Logger logger = LogService.getLogger();
34-
private static final Marker FUNCTION_EXCEPTION_MARKER =
35+
@Immutable
36+
private static final Marker functionExceptionMarker =
3537
MarkerManager.getMarker("FUNCTION_EXCEPTION_MARKER");
3638

3739
DistributedRegionFunctionStreamingMessage msg = null;
@@ -228,7 +230,7 @@ public void setException(Throwable exception) {
228230
} else {
229231
((LocalResultCollector) rc).setException(exception);
230232
// this.lastResult(exception);
231-
logger.info(exception instanceof FunctionException ? FUNCTION_EXCEPTION_MARKER : null,
233+
logger.info(exception instanceof FunctionException ? functionExceptionMarker : null,
232234
"Unexpected exception during function execution on local node Distributed Region",
233235
exception);
234236
}

geode-core/src/main/java/org/apache/geode/internal/cache/execute/MemberFunctionResultSender.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.apache.logging.log4j.Marker;
2020
import org.apache.logging.log4j.MarkerManager;
2121

22+
import org.apache.geode.annotations.Immutable;
2223
import org.apache.geode.cache.execute.Function;
2324
import org.apache.geode.cache.execute.FunctionException;
2425
import org.apache.geode.cache.execute.ResultCollector;
@@ -33,7 +34,8 @@
3334
public class MemberFunctionResultSender implements InternalResultSender {
3435

3536
private static final Logger logger = LogService.getLogger();
36-
private static final Marker FUNCTION_EXCEPTION_MARKER =
37+
@Immutable
38+
private static final Marker functionExceptionMarker =
3739
MarkerManager.getMarker("FUNCTION_EXCEPTION_MARKER");
3840

3941
MemberFunctionStreamingMessage msg = null;
@@ -236,7 +238,7 @@ public void sendException(Throwable exception) {
236238
public void setException(Throwable exception) {
237239
((LocalResultCollector) rc).setException(exception);
238240
// this.lastResult(exception);
239-
logger.info(exception instanceof FunctionException ? FUNCTION_EXCEPTION_MARKER : null,
241+
logger.info(exception instanceof FunctionException ? functionExceptionMarker : null,
240242
"Unexpected exception during function execution local member",
241243
exception);
242244
rc.endResults();

geode-core/src/main/java/org/apache/geode/internal/cache/execute/PartitionedRegionFunctionResultSender.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.apache.logging.log4j.Marker;
2121
import org.apache.logging.log4j.MarkerManager;
2222

23+
import org.apache.geode.annotations.Immutable;
2324
import org.apache.geode.cache.execute.Function;
2425
import org.apache.geode.cache.execute.FunctionException;
2526
import org.apache.geode.cache.execute.ResultCollector;
@@ -44,7 +45,8 @@
4445
public class PartitionedRegionFunctionResultSender implements InternalResultSender {
4546

4647
private static final Logger logger = LogService.getLogger();
47-
private static final Marker FUNCTION_EXCEPTION_MARKER =
48+
@Immutable
49+
private static final Marker functionExceptionMarker =
4850
MarkerManager.getMarker("FUNCTION_EXCEPTION_MARKER");
4951

5052
PartitionedRegionFunctionStreamingMessage msg = null;
@@ -394,7 +396,7 @@ public void setException(Throwable exception) {
394396
serverSender.setException(exception);
395397
} else {
396398
((LocalResultCollector) rc).setException(exception);
397-
logger.info(exception instanceof FunctionException ? FUNCTION_EXCEPTION_MARKER : null,
399+
logger.info(exception instanceof FunctionException ? functionExceptionMarker : null,
398400
"Unexpected exception during function execution on local node Partitioned Region",
399401
exception);
400402
}

geode-core/src/main/java/org/apache/geode/internal/cache/execute/ServerToClientFunctionResultSender.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.apache.logging.log4j.Marker;
2424
import org.apache.logging.log4j.MarkerManager;
2525

26+
import org.apache.geode.annotations.Immutable;
2627
import org.apache.geode.cache.execute.Function;
2728
import org.apache.geode.cache.execute.FunctionException;
2829
import org.apache.geode.cache.execute.ResultSender;
@@ -39,7 +40,8 @@
3940

4041
public class ServerToClientFunctionResultSender implements ResultSender {
4142
private static final Logger logger = LogService.getLogger();
42-
private static final Marker FUNCTION_EXCEPTION_MARKER =
43+
@Immutable
44+
private static final Marker functionExceptionMarker =
4345
MarkerManager.getMarker("FUNCTION_EXCEPTION_MARKER");
4446

4547
protected ChunkedMessage msg = null;
@@ -325,8 +327,8 @@ public synchronized void setException(Throwable exception) {
325327
}
326328
String exceptionMessage = exception.getMessage() != null ? exception.getMessage()
327329
: "Exception occurred during function execution";
328-
logger.warn(exception instanceof FunctionException ? FUNCTION_EXCEPTION_MARKER : null,
329-
String.format("Exception on server while executing function : %s", fn), exception);
330+
logger.warn(exception instanceof FunctionException ? functionExceptionMarker : null,
331+
"Exception on server while executing function : {}", fn, exception);
330332

331333
if (logger.isDebugEnabled()) {
332334
logger.debug("ServerToClientFunctionResultSender sending Function Exception : ");

geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/BaseCommand.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@
9090

9191
public abstract class BaseCommand implements Command {
9292
protected static final Logger logger = LogService.getLogger();
93-
protected static final Marker FUNCTION_EXCEPTION_MARKER =
93+
@Immutable
94+
protected static final Marker functionExceptionMarker =
9495
MarkerManager.getMarker("FUNCTION_EXCEPTION_MARKER");
9596

9697
@Immutable

geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunction70.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ private void executeFunctionLocally(final Function fn, final FunctionContext cx,
433433
}
434434
} catch (FunctionException e) {
435435
stats.endFunctionExecutionWithException(startExecution, fn.hasResult());
436-
logger.warn(FUNCTION_EXCEPTION_MARKER, "Exception on server while executing function: {}",
436+
logger.warn(functionExceptionMarker, "Exception on server while executing function: {}",
437437
fn, e);
438438
} catch (Exception e) {
439439
stats.endFunctionExecutionWithException(startExecution, fn.hasResult());

geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteRegionFunction66.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,9 @@ public void cmdExecute(final @NotNull Message clientMessage,
220220
resultSender.setException(fe);
221221
} else {
222222
if (setLastResultReceived(resultSender)) {
223-
logger.warn(FUNCTION_EXCEPTION_MARKER,
224-
String.format("Exception on server while executing function : %s",
225-
function),
226-
fe);
223+
logger.warn(functionExceptionMarker,
224+
"Exception on server while executing function : {}",
225+
function, fe);
227226
sendException(hasResult, clientMessage, message, serverConnection, fe);
228227
}
229228
}

geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/functions/UserFunctionExecution.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.apache.logging.log4j.MarkerManager;
3333
import org.apache.shiro.subject.Subject;
3434

35+
import org.apache.geode.annotations.Immutable;
3536
import org.apache.geode.cache.Cache;
3637
import org.apache.geode.cache.Region;
3738
import org.apache.geode.cache.execute.Execution;
@@ -58,7 +59,8 @@
5859
public class UserFunctionExecution implements InternalFunction<Object[]> {
5960
private static final long serialVersionUID = 1L;
6061
private static final Logger logger = LogService.getLogger();
61-
private static final Marker FUNCTION_EXCEPTION_MARKER =
62+
@Immutable
63+
private static final Marker functionExceptionMarker =
6264
MarkerManager.getMarker("FUNCTION_EXCEPTION_MARKER");
6365

6466
protected static final String ID =
@@ -251,7 +253,7 @@ public void execute(FunctionContext<Object[]> context) {
251253
CliStrings.EXECUTE_FUNCTION__MSG__RESULT_COLLECTOR_0_NOT_FOUND_ERROR_1,
252254
resultCollectorName, e.getMessage())));
253255
} catch (FunctionException e) {
254-
logger.error(FUNCTION_EXCEPTION_MARKER, "error executing function " + functionId, e);
256+
logger.error(functionExceptionMarker, "error executing function {}", functionId, e);
255257
context.getResultSender().lastResult(
256258
new CliFunctionResult(context.getMemberName(), ERROR, "Exception: " + e.getMessage()));
257259
} catch (Exception e) {

0 commit comments

Comments
 (0)