src/share/jaxws_classes/com/sun/xml/internal/ws/util/ReadAllStream.java

changeset 368
0989ad8c0860
parent 286
f50545b5e2f1
child 637
9c07ef4934dd
     1.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/ws/util/ReadAllStream.java	Thu Apr 04 19:05:24 2013 -0700
     1.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/util/ReadAllStream.java	Tue Apr 09 14:51:13 2013 +0100
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -33,6 +33,8 @@
    1.11  import java.io.FileOutputStream;
    1.12  import java.io.IOException;
    1.13  import java.io.InputStream;
    1.14 +import java.util.logging.Level;
    1.15 +import java.util.logging.Logger;
    1.16  
    1.17  /**
    1.18   * Reads a input stream completely and creates a new stream
    1.19 @@ -48,6 +50,8 @@
    1.20      private boolean readAll;
    1.21      private boolean closed;
    1.22  
    1.23 +    private static final Logger LOGGER = Logger.getLogger(ReadAllStream.class.getName());
    1.24 +
    1.25      public ReadAllStream() {
    1.26          memStream = new MemoryStream();
    1.27          fileStream = new FileStream();
    1.28 @@ -75,6 +79,7 @@
    1.29          }
    1.30      }
    1.31  
    1.32 +    @Override
    1.33      public int read() throws IOException {
    1.34          int ch = memStream.read();
    1.35          if (ch == -1) {
    1.36 @@ -92,6 +97,7 @@
    1.37          return len;
    1.38      }
    1.39  
    1.40 +    @Override
    1.41      public void close() throws IOException {
    1.42          if (!closed) {
    1.43              memStream.close();
    1.44 @@ -120,6 +126,7 @@
    1.45              fin = new FileInputStream(tempFile);
    1.46          }
    1.47  
    1.48 +        @Override
    1.49          public int read() throws IOException {
    1.50              return (fin != null) ? fin.read() : -1;
    1.51          }
    1.52 @@ -135,7 +142,10 @@
    1.53                  fin.close();
    1.54              }
    1.55              if (tempFile != null) {
    1.56 -                tempFile.delete();
    1.57 +                boolean success = tempFile.delete();
    1.58 +                if (!success) {
    1.59 +                    LOGGER.log(Level.INFO, "File {0} could not be deleted", tempFile);
    1.60 +                }
    1.61              }
    1.62          }
    1.63      }
    1.64 @@ -168,12 +178,15 @@
    1.65                  byte[] buf = new byte[8192];
    1.66                  int read = fill(in, buf);
    1.67                  total += read;
    1.68 -                if (read != 0)
    1.69 +                if (read != 0) {
    1.70                      add(buf, read);
    1.71 -                if (read != buf.length)
    1.72 -                    return true;        // EOF
    1.73 -                if (total > inMemory)
    1.74 -                    return false;       // Reached in-memory size
    1.75 +                }
    1.76 +                if (read != buf.length) {
    1.77 +                    return true;
    1.78 +                }        // EOF
    1.79 +                if (total > inMemory) {
    1.80 +                    return false; // Reached in-memory size
    1.81 +                }
    1.82              }
    1.83          }
    1.84  
    1.85 @@ -186,6 +199,7 @@
    1.86              return total;
    1.87          }
    1.88  
    1.89 +        @Override
    1.90          public int read() throws IOException {
    1.91              if (!fetch()) {
    1.92                  return -1;

mercurial