Author: bodewig
Date: Tue Jan  7 18:48:56 2014
New Revision: 1556311

URL: http://svn.apache.org/r1556311
Log:
deal with missing owner information

Modified:
    
commons/proper/compress/branches/compress-2.0/src/main/java/org/apache/commons/compress2/formats/ar/ArArchiveOutput.java

Modified: 
commons/proper/compress/branches/compress-2.0/src/main/java/org/apache/commons/compress2/formats/ar/ArArchiveOutput.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/branches/compress-2.0/src/main/java/org/apache/commons/compress2/formats/ar/ArArchiveOutput.java?rev=1556311&r1=1556310&r2=1556311&view=diff
==============================================================================
--- 
commons/proper/compress/branches/compress-2.0/src/main/java/org/apache/commons/compress2/formats/ar/ArArchiveOutput.java
 (original)
+++ 
commons/proper/compress/branches/compress-2.0/src/main/java/org/apache/commons/compress2/formats/ar/ArArchiveOutput.java
 Tue Jan  7 18:48:56 2014
@@ -24,6 +24,7 @@ import java.nio.channels.WritableByteCha
 import java.nio.charset.StandardCharsets;
 
 import org.apache.commons.compress2.archivers.ArchiveEntryParameters;
+import org.apache.commons.compress2.archivers.OwnerInformation;
 import org.apache.commons.compress2.archivers.spi.AbstractArchiveOutput;
 
 /**
@@ -159,14 +160,14 @@ public class ArArchiveOutput extends Abs
         offset += write(m);
 
         offset = fill(offset, 28, (byte) ' ');
-        final String u = "" + pEntry.getOwnerInformation().getUserId();
+        final String u = "" + getUserId(pEntry.getOwnerInformation());
         if (u.length() > 6) {
             throw new IOException("userid too long");
         }
         offset += write(u);
 
         offset = fill(offset, 34, (byte) ' ');
-        final String g = "" + pEntry.getOwnerInformation().getGroupId();
+        final String g = "" + getGroupId(pEntry.getOwnerInformation());
         if (g.length() > 6) {
             throw new IOException("groupid too long");
         }
@@ -238,4 +239,12 @@ public class ArArchiveOutput extends Abs
     public boolean isOpen() {
         return out.isOpen();
     }
+
+    private int getUserId(OwnerInformation info) {
+        return info == null ? 0 : info.getUserId();
+    }
+
+    private int getGroupId(OwnerInformation info) {
+        return info == null ? 0 : info.getGroupId();
+    }
 }


Reply via email to