This is an automated email from the ASF dual-hosted git repository.

pivotalsarge pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new 1f2193b  GEODE-4402: Add logging where exceptions would be thrown or 
caught. (#1452)
1f2193b is described below

commit 1f2193bdfc7845e40ff75e6bde16840cdce7269a
Author: Michael "Sarge" Dodge <mdo...@pivotal.io>
AuthorDate: Fri Feb 23 07:56:54 2018 -0800

    GEODE-4402: Add logging where exceptions would be thrown or caught. (#1452)
    
    * GEODE-4402: Add logging where exceptions would be thrown or caught.
    
    * GEODE-4402: Address review comments.
    
    * GEODE-4402: Add another ignore exception.
    
    * GEODE-4402: Fix spotless.
    
    * Adding log messages that were lost on the merge commit
---
 .../v1/LocatorMessageExecutionContext.java         |  2 --
 .../protocol/protobuf/v1/ProtobufOpsProcessor.java |  2 +-
 .../protobuf/v1/ProtobufSerializationService.java  |  1 -
 .../protobuf/v1/ProtobufStreamProcessor.java       |  1 +
 .../protobuf/v1/ServerMessageExecutionContext.java |  2 --
 .../AbstractFunctionRequestOperationHandler.java   | 22 +++++++++++++---------
 .../v1/operations/ProtocolVersionHandler.java      |  4 ----
 .../AuthenticationRequestOperationHandler.java     |  8 ++++++++
 .../v1/acceptance/LocatorConnectionDUnitTest.java  |  3 +++
 9 files changed, 26 insertions(+), 19 deletions(-)

diff --git 
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/LocatorMessageExecutionContext.java
 
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/LocatorMessageExecutionContext.java
index a38f49c..b615326 100644
--- 
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/LocatorMessageExecutionContext.java
+++ 
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/LocatorMessageExecutionContext.java
@@ -15,7 +15,6 @@
 
 package org.apache.geode.internal.protocol.protobuf.v1;
 
-
 import org.apache.geode.annotations.Experimental;
 import org.apache.geode.distributed.Locator;
 import org.apache.geode.internal.cache.InternalCache;
@@ -57,5 +56,4 @@ public class LocatorMessageExecutionContext extends 
MessageExecutionContext {
   public Locator getLocator() throws InvalidExecutionContextException {
     return locator;
   }
-
 }
diff --git 
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ProtobufOpsProcessor.java
 
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ProtobufOpsProcessor.java
index 7f1996c..eca629d 100644
--- 
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ProtobufOpsProcessor.java
+++ 
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ProtobufOpsProcessor.java
@@ -32,7 +32,6 @@ import 
org.apache.geode.internal.protocol.protobuf.v1.state.exception.OperationN
  */
 @Experimental
 public class ProtobufOpsProcessor {
-
   private final ProtobufOperationContextRegistry 
protobufOperationContextRegistry;
   private final ProtobufSerializationService serializationService;
   private static final Logger logger = 
LogService.getLogger(ProtobufOpsProcessor.class);
@@ -81,6 +80,7 @@ public class ProtobufOpsProcessor {
           operationContext.getFromRequest().apply(request), context);
     } catch (InvalidExecutionContextException exception) {
       logger.error("Invalid execution context found for operation {}", 
requestType);
+      logger.error(exception);
       return Failure.of(BasicTypes.ErrorCode.INVALID_REQUEST,
           "Invalid execution context found for operation.");
     }
diff --git 
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ProtobufSerializationService.java
 
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ProtobufSerializationService.java
index e2a8429..d20b05e 100644
--- 
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ProtobufSerializationService.java
+++ 
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ProtobufSerializationService.java
@@ -171,5 +171,4 @@ public class ProtobufSerializationService implements 
SerializationService<BasicT
           "There is no primitive protobuf type mapping for class:" + 
unencodedValueClass);
     }
   }
-
 }
diff --git 
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ProtobufStreamProcessor.java
 
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ProtobufStreamProcessor.java
index ac2e9e9..e72774f 100644
--- 
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ProtobufStreamProcessor.java
+++ 
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ProtobufStreamProcessor.java
@@ -51,6 +51,7 @@ public class ProtobufStreamProcessor {
     try {
       processOneMessage(inputStream, outputStream, executionContext);
     } catch (InvalidProtocolMessageException e) {
+      logger.info(e);
       throw new IOException(e);
     }
   }
diff --git 
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ServerMessageExecutionContext.java
 
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ServerMessageExecutionContext.java
index 1abd1ad..efb5430 100644
--- 
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ServerMessageExecutionContext.java
+++ 
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ServerMessageExecutionContext.java
@@ -15,7 +15,6 @@
 
 package org.apache.geode.internal.protocol.protobuf.v1;
 
-
 import org.apache.geode.annotations.Experimental;
 import org.apache.geode.distributed.Locator;
 import org.apache.geode.internal.cache.InternalCache;
@@ -55,5 +54,4 @@ public class ServerMessageExecutionContext extends 
MessageExecutionContext {
     throw new InvalidExecutionContextException(
         "Operations on the server should not to try to operate on a locator");
   }
-
 }
diff --git 
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/AbstractFunctionRequestOperationHandler.java
 
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/AbstractFunctionRequestOperationHandler.java
index 3a2890c..548e9ba 100644
--- 
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/AbstractFunctionRequestOperationHandler.java
+++ 
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/AbstractFunctionRequestOperationHandler.java
@@ -17,6 +17,8 @@ package 
org.apache.geode.internal.protocol.protobuf.v1.operations;
 import java.util.List;
 import java.util.Set;
 
+import org.apache.logging.log4j.Logger;
+
 import org.apache.geode.cache.execute.Execution;
 import org.apache.geode.cache.execute.Function;
 import org.apache.geode.cache.execute.FunctionException;
@@ -24,6 +26,7 @@ import org.apache.geode.cache.execute.FunctionService;
 import org.apache.geode.cache.execute.ResultCollector;
 import org.apache.geode.internal.exception.InvalidExecutionContextException;
 import org.apache.geode.internal.i18n.LocalizedStrings;
+import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.internal.protocol.operations.ProtobufOperationHandler;
 import org.apache.geode.internal.protocol.protobuf.v1.BasicTypes;
 import org.apache.geode.internal.protocol.protobuf.v1.Failure;
@@ -37,7 +40,7 @@ import org.apache.geode.security.NotAuthorizedException;
 
 public abstract class AbstractFunctionRequestOperationHandler<Req, Resp>
     implements ProtobufOperationHandler<Req, Resp> {
-
+  private static final Logger logger = LogService.getLogger();
 
   @Override
   public Result<Resp> process(ProtobufSerializationService 
serializationService, Req request,
@@ -60,8 +63,9 @@ public abstract class 
AbstractFunctionRequestOperationHandler<Req, Resp>
       // check security for function.
       
function.getRequiredPermissions(regionName).forEach(securityService::authorize);
     } catch (NotAuthorizedException ex) {
-      return Failure.of(BasicTypes.ErrorCode.AUTHORIZATION_FAILED,
-          "Authorization failed for function \"" + functionID + "\"");
+      final String message = "Authorization failed for function \"" + 
functionID + "\"";
+      logger.warn(message, ex);
+      return Failure.of(BasicTypes.ErrorCode.AUTHORIZATION_FAILED, message);
     }
 
     Object executionTarget = getExecutionTarget(request, regionName, 
messageExecutionContext);
@@ -94,10 +98,13 @@ public abstract class 
AbstractFunctionRequestOperationHandler<Req, Resp>
         return buildResultMessage(serializationService);
       }
     } catch (FunctionException ex) {
-      return Failure.of(BasicTypes.ErrorCode.SERVER_ERROR,
-          "Function execution failed: " + ex.toString());
+      final String message = "Function execution failed: " + ex.toString();
+      logger.info(message, ex);
+      return Failure.of(BasicTypes.ErrorCode.SERVER_ERROR, message);
     } catch (EncodingException ex) {
-      return Failure.of(BasicTypes.ErrorCode.SERVER_ERROR, "Encoding failed: " 
+ ex.toString());
+      final String message = "Encoding failed: " + ex.toString();
+      logger.info(message, ex);
+      return Failure.of(BasicTypes.ErrorCode.SERVER_ERROR, message);
     }
   }
 
@@ -126,7 +133,4 @@ public abstract class 
AbstractFunctionRequestOperationHandler<Req, Resp>
 
   protected abstract Result buildResultMessage(ProtobufSerializationService 
serializationService,
       List<Object> results) throws EncodingException;
-
-
-
 }
diff --git 
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/ProtocolVersionHandler.java
 
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/ProtocolVersionHandler.java
index fea33b0..d9cfbed 100644
--- 
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/ProtocolVersionHandler.java
+++ 
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/ProtocolVersionHandler.java
@@ -18,14 +18,10 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
 import org.apache.geode.internal.protocol.protobuf.ProtocolVersion;
 import org.apache.geode.internal.protocol.protobuf.statistics.ClientStatistics;
 
 public class ProtocolVersionHandler {
-  private static final Logger logger = LogManager.getLogger();
   private static final VersionValidator validator = new VersionValidator();
 
   public static boolean handleVersionMessage(InputStream inputStream, 
OutputStream outputStream,
diff --git 
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/security/AuthenticationRequestOperationHandler.java
 
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/security/AuthenticationRequestOperationHandler.java
index abe6c1a..5d7f44c 100644
--- 
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/security/AuthenticationRequestOperationHandler.java
+++ 
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/security/AuthenticationRequestOperationHandler.java
@@ -16,6 +16,11 @@ package 
org.apache.geode.internal.protocol.protobuf.v1.operations.security;
 
 import java.util.Properties;
 
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import org.apache.geode.internal.exception.InvalidExecutionContextException;
+import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.internal.protocol.operations.ProtobufOperationHandler;
 import org.apache.geode.internal.protocol.protobuf.v1.ConnectionAPI;
 import org.apache.geode.internal.protocol.protobuf.v1.MessageExecutionContext;
@@ -30,6 +35,8 @@ import 
org.apache.geode.security.AuthenticationFailedException;
 
 public class AuthenticationRequestOperationHandler implements
     ProtobufOperationHandler<ConnectionAPI.AuthenticationRequest, 
ConnectionAPI.AuthenticationResponse> {
+  private static final Logger logger = LogService.getLogger();
+
   @Override
   public Result<ConnectionAPI.AuthenticationResponse> process(
       ProtobufSerializationService serializationService,
@@ -49,6 +56,7 @@ public class AuthenticationRequestOperationHandler implements
       return Success
           
.of(ConnectionAPI.AuthenticationResponse.newBuilder().setAuthenticated(true).build());
     } catch (AuthenticationFailedException e) {
+      logger.warn("Authentication failed", e);
       messageExecutionContext
           .setConnectionStateProcessor(new 
ProtobufConnectionTerminatingStateProcessor());
       return Success
diff --git 
a/geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/acceptance/LocatorConnectionDUnitTest.java
 
b/geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/acceptance/LocatorConnectionDUnitTest.java
index f30ef14..48650da 100644
--- 
a/geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/acceptance/LocatorConnectionDUnitTest.java
+++ 
b/geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/acceptance/LocatorConnectionDUnitTest.java
@@ -118,6 +118,8 @@ public class LocatorConnectionDUnitTest extends 
JUnit4CacheTestCase {
       throws IOException, InvalidProtocolMessageException {
     IgnoredException ignoredInvalidExecutionContext =
         IgnoredException.addIgnoredException("Invalid execution context");
+    IgnoredException ignoredOperationsOnTheLocator = IgnoredException
+        .addIgnoredException("Operations on the locator should not to try to 
operate on a server");
     try (Socket socket = createSocket()) {
       ClientProtocol.Message getRegionNamesRequestMessage = 
ClientProtocol.Message.newBuilder()
           
.setGetRegionNamesRequest(ProtobufRequestUtilities.createGetRegionNamesRequest()).build();
@@ -144,6 +146,7 @@ public class LocatorConnectionDUnitTest extends 
JUnit4CacheTestCase {
           bytesSent + getAvailableServersResponseMessage.getSerializedSize(),
           clientConnectionStarts, clientConnectionTerminations + 1);
     }
+    ignoredOperationsOnTheLocator.remove();
     ignoredInvalidExecutionContext.remove();
   }
 

-- 
To stop receiving notification emails like this one, please contact
pivotalsa...@apache.org.

Reply via email to