jchen21 commented on a change in pull request #7121:
URL: https://github.com/apache/geode/pull/7121#discussion_r751561344



##########
File path: 
geode-junit/src/main/java/org/apache/geode/codeAnalysis/AnalyzeDataSerializablesTestBase.java
##########
@@ -209,7 +201,7 @@ public void testExcludedClassesExistAndDoNotDeserialize() 
throws Exception {
         final Object excludedInstance;
         try {
           excludedInstance = excludedClass.newInstance();
-        } catch (InstantiationException | IllegalAccessException e) {
+        } catch (InstantiationException | IllegalAccessException | 
NullPointerException e) {

Review comment:
       Why there is `NullPointerException` here? Better add some comment here.

##########
File path: 
geode-junit/src/main/java/org/apache/geode/codeAnalysis/AnalyzeDataSerializablesTestBase.java
##########
@@ -230,10 +222,18 @@ private void serializeAndDeserializeObject(Object object) 
throws Exception {
     BufferDataOutputStream outputStream = new 
BufferDataOutputStream(KnownVersion.CURRENT);
     try {
       serializeObject(object, outputStream);
-    } catch (IOException e) {
+    } catch (IOException | NullPointerException e) {
       // some classes, such as BackupLock, are Serializable because the extend 
something
       // like ReentrantLock but we never serialize them & it doesn't work to 
try to do so
       System.out.println("Not Serializable: " + object.getClass().getName());
+      return;
+    } catch (Exception e) {

Review comment:
       Why not catch `CacheClosedException` here, instead of `Exception`?

##########
File path: 
geode-junit/src/main/java/org/apache/geode/codeAnalysis/AnalyzeSerializablesTestBase.java
##########
@@ -339,22 +351,23 @@ protected void serializeObject(Object object, 
BufferDataOutputStream outputStrea
 
   private void serializeAndDeserializeSanctionedObject(Object object) throws 
Exception {
     BufferDataOutputStream outputStream = new 
BufferDataOutputStream(KnownVersion.CURRENT);
+
     try {
       serializeObject(object, outputStream);
     } catch (RemoteException e) {
-      fail(object.getClass().getName() +
-          " is a java.rmi.server.RemoteObject which is not supported by 
AnalyzeSerializables", e);
-    } catch (IOException e) {
-      // some classes, such as BackupLock, are Serializable because the extend 
something
-      // like ReentrantLock but we never serialize them & it doesn't work to 
try to do so
-      throw new AssertionError("Not Serializable: " + 
object.getClass().getName(), e);
+      // java.rmi.server.RemoteObject which is not supported by 
AnalyzeSerializables
+    } catch (Exception e) {
+      errorCollector.addError(
+          new AssertionError("Not Serializable: " + 
object.getClass().getName(), e));
     }
+
     try {
       deserializeObject(outputStream);
     } catch (CancelException e) {
       // PDX classes fish for a PDXRegistry and find that there is no cache
-    } catch (InvalidClassException e) {
-      fail("I was unable to deserialize " + object.getClass().getName(), e);
+    } catch (Exception e) {
+      errorCollector.addError(
+          new AssertionError("I was unable to deserialize " + 
object.getClass().getName(), e));

Review comment:
       Better have consistent error message with line 361.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to