Author: sebb
Date: Sat Mar 31 18:24:38 2012
New Revision: 1307868

URL: http://svn.apache.org/viewvc?rev=1307868&view=rev
Log:
COMPRESS-180 new String(byte[]) conversions use default encoding
Document where the charset might need specifying

Modified:
    
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java
    
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStream.java
    
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveSummary.java
    
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
    
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java?rev=1307868&r1=1307867&r2=1307868&view=diff
==============================================================================
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java
 Sat Mar 31 18:24:38 2012
@@ -385,7 +385,7 @@ public class CpioArchiveInputStream exte
     private String readCString(final int length) throws IOException {
         byte tmpBuffer[] = new byte[length];
         readFully(tmpBuffer, 0, tmpBuffer.length);
-        return new String(tmpBuffer, 0, tmpBuffer.length - 1);
+        return new String(tmpBuffer, 0, tmpBuffer.length - 1); // TODO default 
charset?
     }
 
     /**

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStream.java?rev=1307868&r1=1307867&r2=1307868&view=diff
==============================================================================
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStream.java
 Sat Mar 31 18:24:38 2012
@@ -326,7 +326,7 @@ public class DumpArchiveInputStream exte
 
                 byte type = blockBuffer[i + 6];
 
-                String name = new String(blockBuffer, i + 8, blockBuffer[i + 
7]);
+                String name = new String(blockBuffer, i + 8, blockBuffer[i + 
7]); // TODO default charset?
 
                 if (".".equals(name) || "..".equals(name)) {
                     // do nothing...

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveSummary.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveSummary.java?rev=1307868&r1=1307867&r2=1307868&view=diff
==============================================================================
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveSummary.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveSummary.java
 Sat Mar 31 18:24:38 2012
@@ -45,11 +45,11 @@ public class DumpArchiveSummary {
         dumpDate = 1000L * DumpArchiveUtil.convert32(buffer, 4);
         previousDumpDate = 1000L * DumpArchiveUtil.convert32(buffer, 8);
         volume = DumpArchiveUtil.convert32(buffer, 12);
-        label = new String(buffer, 676, DumpArchiveConstants.LBLSIZE).trim();
+        label = new String(buffer, 676, DumpArchiveConstants.LBLSIZE).trim(); 
// TODO default charset?
         level = DumpArchiveUtil.convert32(buffer, 692);
-        filesys = new String(buffer, 696, DumpArchiveConstants.NAMELEN).trim();
-        devname = new String(buffer, 760, DumpArchiveConstants.NAMELEN).trim();
-        hostname = new String(buffer, 824, 
DumpArchiveConstants.NAMELEN).trim();
+        filesys = new String(buffer, 696, 
DumpArchiveConstants.NAMELEN).trim(); // TODO default charset?
+        devname = new String(buffer, 760, 
DumpArchiveConstants.NAMELEN).trim(); // TODO default charset?
+        hostname = new String(buffer, 824, 
DumpArchiveConstants.NAMELEN).trim(); // TODO default charset?
         flags = DumpArchiveUtil.convert32(buffer, 888);
         firstrec = DumpArchiveUtil.convert32(buffer, 892);
         ntrec = DumpArchiveUtil.convert32(buffer, 896);

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java?rev=1307868&r1=1307867&r2=1307868&view=diff
==============================================================================
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
 Sat Mar 31 18:24:38 2012
@@ -249,7 +249,7 @@ public class TarArchiveInputStream exten
             byte[] buf = new byte[SMALL_BUFFER_SIZE];
             int length = 0;
             while ((length = read(buf)) >= 0) {
-                longName.append(new String(buf, 0, length));
+                longName.append(new String(buf, 0, length)); // TODO default 
charset?
             }
             getNextEntry();
             if (currEntry == null) {

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java?rev=1307868&r1=1307867&r2=1307868&view=diff
==============================================================================
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
 Sat Mar 31 18:24:38 2012
@@ -235,7 +235,7 @@ public class TarUtils {
     // Helper method to generate the exception message
     private static String exceptionMessage(byte[] buffer, final int offset,
             final int length, int current, final byte currentByte) {
-        String string = new String(buffer, offset, length);
+        String string = new String(buffer, offset, length); // TODO default 
charset?
         string=string.replaceAll("\0", "{NUL}"); // Replace NULs to allow 
string to be printed
         final String s = "Invalid byte "+currentByte+" at offset 
"+(current-offset)+" in '"+string+"' len="+length;
         return s;


Reply via email to