You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2020/12/15 09:26:46 UTC

[wicket] 02/02: Improve logging in JavaSerializer

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

mgrigorov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/wicket.git

commit b68a9554c6ca54bb5bdd1f54a2b60a71b869a32a
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
AuthorDate: Tue Dec 15 11:26:15 2020 +0200

    Improve logging in JavaSerializer
---
 .../wicket/serialize/java/JavaSerializer.java      | 27 ++++++++++------------
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/wicket-core/src/main/java/org/apache/wicket/serialize/java/JavaSerializer.java b/wicket-core/src/main/java/org/apache/wicket/serialize/java/JavaSerializer.java
index 4628999..62ded9a 100644
--- a/wicket-core/src/main/java/org/apache/wicket/serialize/java/JavaSerializer.java
+++ b/wicket-core/src/main/java/org/apache/wicket/serialize/java/JavaSerializer.java
@@ -111,8 +111,8 @@ public class JavaSerializer implements ISerializer
 		}
 		catch (Exception e)
 		{
-			log.error("Error serializing object " + object.getClass() + " [object=" + object + "]",
-				e);
+			log.error("Error serializing object {} [object={}]",
+			          object.getClass(), object, e);
 		}
 		return null;
 	}
@@ -155,7 +155,7 @@ public class JavaSerializer implements ISerializer
 		}
 		catch (ClassNotFoundException | IOException cnfx)
 		{
-			throw new RuntimeException("Could not deserialize object from byte[]", cnfx);
+			throw new WicketRuntimeException("Could not deserialize object from byte[]", cnfx);
 		}
 		finally
 		{
@@ -292,7 +292,7 @@ public class JavaSerializer implements ISerializer
 			{
 				// ignore this exception.
 				log.debug(
-					"Proxy Class not found by the object outputstream itself, trying the IClassResolver");
+					"Proxy Class not found by the ObjectOutputStream itself, trying the IClassResolver");
 
 				ClassLoader latestLoader = latestUserDefinedLoader();
 				ClassLoader nonPublicLoader = null;
@@ -392,18 +392,15 @@ public class JavaSerializer implements ISerializer
 						CheckingObjectOutputStream checkingObjectOutputStream =
 							new CheckingObjectOutputStream(outputStream, new ObjectSerializationChecker(nsx));
 						checkingObjectOutputStream.writeObject(obj);
-					} 
+					}
+					catch (CheckingObjectOutputStream.ObjectCheckException x)
+					{
+						throw x;
+					}
 					catch (Exception x)
 					{
-						if (x instanceof CheckingObjectOutputStream.ObjectCheckException)
-						{
-							throw (CheckingObjectOutputStream.ObjectCheckException) x;
-						}
-						else
-						{
-							x.initCause(nsx);
-							throw new WicketRuntimeException("A problem occurred while trying to collect debug information about not serializable object", x);
-						}
+						x.initCause(nsx);
+						throw new WicketRuntimeException("A problem occurred while trying to collect debug information about not serializable object", x);
 					}
 
 					// if we get here, we didn't fail, while we should
@@ -413,7 +410,7 @@ public class JavaSerializer implements ISerializer
 			}
 			catch (Exception e)
 			{
-				log.error("error writing object " + obj + ": " + e.getMessage(), e);
+				log.error("error writing object {} : {}", obj, e.getMessage(), e);
 				throw new WicketRuntimeException(e);
 			}
 		}