Author: syoung
Date: 2006-04-14 18:54:46 +0000 (Fri, 14 Apr 2006)
New Revision: 8554

Modified:
   trunk/freenet/src/freenet/config/StringArrOption.java
   trunk/freenet/src/freenet/node/Version.java
   trunk/freenet/src/freenet/node/fcp/FCPClient.java
   trunk/freenet/src/freenet/support/SimpleFieldSet.java
   trunk/freenet/src/freenet/support/compress/Compressor.java
   trunk/freenet/src/freenet/support/io/FilenameGenerator.java
Log:
FilenameGenerator: Fix an NPE when the default temporary directory was used, 
indicating by passing "null" for the dir parameter.
SimpleFieldSet: Remove unused constructor that never worked.
FCPClient: Fix an NPE when there are too many unacknowledged completed 
requests, fixed unsynchronized access to the current connection

Modified: trunk/freenet/src/freenet/config/StringArrOption.java
===================================================================
--- trunk/freenet/src/freenet/config/StringArrOption.java       2006-04-14 
15:07:57 UTC (rev 8553)
+++ trunk/freenet/src/freenet/config/StringArrOption.java       2006-04-14 
18:54:46 UTC (rev 8554)
@@ -6,11 +6,11 @@

 public class StringArrOption extends Option {

-       final String defaultValue;
-       final StringArrCallback cb;
+    private final String defaultValue;
+    private final StringArrCallback cb;
        private String currentValue;

-       public static String delimiter = ";";
+    public static final String delimiter = ";";

        public StringArrOption(SubConfig conf, String optionName, String 
defaultValue, int sortOrder, 
                        boolean expert, String shortDesc, String longDesc, 
StringArrCallback cb) {

Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2006-04-14 15:07:57 UTC (rev 
8553)
+++ trunk/freenet/src/freenet/node/Version.java 2006-04-14 18:54:46 UTC (rev 
8554)
@@ -20,7 +20,7 @@
        public static final String protocolVersion = "1.0";

        /** The build number of the current revision */
-       private static final int buildNumber = 646;
+       private static final int buildNumber = 647;

        /** Oldest build of Fred we will talk to */
        private static final int lastGoodBuild = 591;

Modified: trunk/freenet/src/freenet/node/fcp/FCPClient.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/FCPClient.java   2006-04-14 15:07:57 UTC 
(rev 8553)
+++ trunk/freenet/src/freenet/node/fcp/FCPClient.java   2006-04-14 18:54:46 UTC 
(rev 8554)
@@ -85,19 +85,20 @@
        public void finishedClientRequest(ClientRequest get) {
                ClientRequest dropped = null;
                synchronized(this) {
-                       if(runningPersistentRequests.remove(get))
+                       if(runningPersistentRequests.remove(get)) {
                                completedUnackedRequests.push(get);
-                       
+                       }       
                        if(completedUnackedRequests.size() > 
MAX_UNACKED_REQUESTS) {
+                               dropped = (ClientRequest) 
completedUnackedRequests.pop();
                                
clientRequestsByIdentifier.remove(dropped.getIdentifier());
-                               dropped = (ClientRequest) 
completedUnackedRequests.pop();
                        }
                }
                if(dropped != null) {
                        dropped.dropped();
                }
-               if(get.isPersistentForever())
+               if(get.isPersistentForever()) {
                        server.forceStorePersistentRequests();
+               }
        }

        /**
@@ -192,7 +193,7 @@
                        watchGlobal = false;
                } else if(enabled && !watchGlobal) {
                        server.globalClient.watch(this);
-                       FCPConnectionHandler connHandler = currentConnection;
+                       FCPConnectionHandler connHandler = getConnection();
                        if(connHandler != null) {
                                
server.globalClient.queuePendingMessagesOnConnectionRestart(connHandler.outputHandler);
                        }

Modified: trunk/freenet/src/freenet/support/SimpleFieldSet.java
===================================================================
--- trunk/freenet/src/freenet/support/SimpleFieldSet.java       2006-04-14 
15:07:57 UTC (rev 8553)
+++ trunk/freenet/src/freenet/support/SimpleFieldSet.java       2006-04-14 
18:54:46 UTC (rev 8554)
@@ -22,9 +22,9 @@
  */
 public class SimpleFieldSet {

-       final Map map;
-    String endMarker;
-    final boolean multiLevel;
+    private final Map map;
+    private String endMarker;
+    private final boolean multiLevel;
     static public final char MULTI_LEVEL_CHAR = '.';

     public SimpleFieldSet(BufferedReader br, boolean multiLevel) throws 
IOException {
@@ -58,21 +58,6 @@
         BufferedReader br = new BufferedReader(sr);
            read(br);
     }
-
-    /**
-     * Construct from a string[].
-     * @throws IOException if the string is too short or invalid.
-     */
-    public SimpleFieldSet(String[] content, boolean multiLevel) throws 
IOException {
-        map = new HashMap();
-        this.multiLevel = multiLevel;
-        String content2=new String();
-        for(int i=0;i<content.length;i++)
-               content2.concat(content[i]+";");
-        StringReader sr = new StringReader(content2);
-        BufferedReader br = new BufferedReader(sr);
-           read(br);
-    }

     /**
      * Read from disk

Modified: trunk/freenet/src/freenet/support/compress/Compressor.java
===================================================================
--- trunk/freenet/src/freenet/support/compress/Compressor.java  2006-04-14 
15:07:57 UTC (rev 8553)
+++ trunk/freenet/src/freenet/support/compress/Compressor.java  2006-04-14 
18:54:46 UTC (rev 8554)
@@ -12,7 +12,7 @@
  */
 public abstract class Compressor {

-       public static Compressor gzip = new GzipCompressor();
+    public static final Compressor GZIP = new GzipCompressor();

        public abstract Bucket compress(Bucket data, BucketFactory bf, long 
maxLength) throws IOException, CompressionOutputSizeException;

@@ -40,14 +40,14 @@

        public static Compressor getCompressionAlgorithmByDifficulty(int i) {
                if(i == 0)
-                       return Compressor.gzip;
+            return GZIP;
                // FIXME when we get more compression algos, put them here.
                return null;
        }

        public static Compressor getCompressionAlgorithmByMetadataID(short 
algo) {
                if(algo == Metadata.COMPRESS_GZIP)
-                       return gzip;
+            return GZIP;
                // FIXME when we get more compression algos, put them here.
                return null;
        }

Modified: trunk/freenet/src/freenet/support/io/FilenameGenerator.java
===================================================================
--- trunk/freenet/src/freenet/support/io/FilenameGenerator.java 2006-04-14 
15:07:57 UTC (rev 8553)
+++ trunk/freenet/src/freenet/support/io/FilenameGenerator.java 2006-04-14 
18:54:46 UTC (rev 8554)
@@ -8,10 +8,17 @@

 public class FilenameGenerator {

-       final RandomSource random;
-       final String prefix;
-       final File tmpDir;
-       
+    private final RandomSource random;
+    private final String prefix;
+    private final File tmpDir;
+
+    /**
+     * @param random
+     * @param wipeFiles
+     * @param dir if <code>null</code> then use the default temporary directory
+     * @param prefix
+     * @throws IOException
+     */
        public FilenameGenerator(RandomSource random, boolean wipeFiles, File 
dir, String prefix) throws IOException {
                this.random = random;
                this.prefix = prefix;
@@ -19,8 +26,8 @@
                        tmpDir = new File(System.getProperty("java.io.tmpdir"));
                else
                        tmpDir = dir;
-               if(!dir.exists()) {
-                       dir.mkdir();
+        if(!tmpDir.exists()) {
+            tmpDir.mkdir();
                }
                if(!(tmpDir.isDirectory() && tmpDir.canRead() && 
tmpDir.canWrite()))
                        throw new IOException("Not a directory or cannot 
read/write: "+tmpDir);


Reply via email to