[logback-dev] svn commit: r1644 - in logback/trunk/logback-classic/src: main/java/ch/qos/logback/classic/spi test/java/ch/qos/logback/classic/spi

noreply.ceki at qos.ch noreply.ceki at qos.ch
Thu Mar 13 17:09:56 CET 2008


Author: ceki
Date: Thu Mar 13 17:09:56 2008
New Revision: 1644

Modified:
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationTest.java

Log:
- support strings of unlimited length

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java	Thu Mar 13 17:09:56 2008
@@ -42,17 +42,11 @@
  */
 public class LoggingEvent implements Serializable {
 
-  /**
-   * 
-   */
-  private static final long serialVersionUID = 3022264832697160750L;
+  private static final long serialVersionUID = 3075964498087694229L;
 
   private static final int NULL_ARGUMENT_ARRAY = -1;
   private static final String NULL_ARGUMENT_ARRAY_ELEMENT = "NULL_ARGUMENT_ARRAY_ELEMENT";
   
-  // writeUTF method in ObjectOutputStream has a size limit of 2*16;
-  static final int UTF_SIZE_LIMIT = 0xFFFF;
-  
   /**
    * 
    */
@@ -298,9 +292,9 @@
       out.writeInt(len);
       for (int i = 0; i < argumentArray.length; i++) {
         if (argumentArray[i] != null) {
-          out.writeUTF(cap(argumentArray[i].toString()));
+          out.writeObject(argumentArray[i].toString());
         } else {
-          out.writeUTF(NULL_ARGUMENT_ARRAY_ELEMENT);
+          out.writeObject(NULL_ARGUMENT_ARRAY_ELEMENT);
         }
       }
     } else {
@@ -309,18 +303,6 @@
 
   }
 
-  /**
-   * writeUTF method cannot handle large strings
-   * @param in
-   * @return
-   */
-  final String cap(String in) {
-    if(in.length() > UTF_SIZE_LIMIT) {
-      return in.substring(0, UTF_SIZE_LIMIT);
-    } else {
-      return in;
-    }
-  }
   private void readObject(ObjectInputStream in) throws IOException,
       ClassNotFoundException {
     in.defaultReadObject();
@@ -331,7 +313,7 @@
     if (argArrayLen != NULL_ARGUMENT_ARRAY) {
       argumentArray = new String[argArrayLen];
       for (int i = 0; i < argArrayLen; i++) {
-        String val = in.readUTF();
+        Object val = in.readObject();
         if (!NULL_ARGUMENT_ARRAY_ELEMENT.equals(val)) {
           argumentArray[i] = val;
         }

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationTest.java	Thu Mar 13 17:09:56 2008
@@ -3,7 +3,6 @@
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -154,9 +153,7 @@
     assertNotNull(aa);
     assertEquals(2, aa.length);
     String stringBack = (String) aa[1];
-    
-    assertTrue(stringBack.startsWith("X"));
-    assertEquals(LoggingEvent.UTF_SIZE_LIMIT, stringBack.length());
+    assertEquals(largeString, stringBack);
   }
 
   private LoggingEvent createLoggingEvent() {



More information about the logback-dev mailing list