]> source.dussan.org Git - jgit.git/commitdiff
Add a no-op UploadPackLogger and use it by default 68/4768/2
authorDave Borowitz <dborowitz@google.com>
Thu, 8 Dec 2011 16:00:39 +0000 (08:00 -0800)
committerDave Borowitz <dborowitz@google.com>
Thu, 8 Dec 2011 16:26:08 +0000 (08:26 -0800)
This matches the behavior of the hooks in UploadPack.

Change-Id: I21277e52ee9452237d87084f06bb140dfa6bf608

org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPackLogger.java

index ca3d24790c1ff0b2e2d1e8b9d567f9aab7297b88..2fa6e5cff09580ddb157c514f7a8028cad38dd55 100644 (file)
@@ -217,7 +217,7 @@ public class UploadPack {
 
        private PackWriter.Statistics statistics;
 
-       private UploadPackLogger logger;
+       private UploadPackLogger logger = UploadPackLogger.NULL;
 
        /**
         * Create a new pack upload for an open repository.
@@ -376,6 +376,11 @@ public class UploadPack {
                this.packConfig = pc;
        }
 
+       /** @return the configured logger. */
+       public UploadPackLogger getLogger() {
+               return logger;
+       }
+
        /**
         * Set the logger.
         *
@@ -1111,7 +1116,7 @@ public class UploadPack {
                if (sideband)
                        pckOut.end();
 
-               if (logger != null && statistics != null)
+               if (statistics != null)
                        logger.onPackStatistics(statistics);
        }
 }
index 6e37b837b8ba098d7ca0842607ce48361433c8c2..45f91ed81c1bb6fb8f282ee29217f9e4dc5a0a40 100644 (file)
@@ -54,6 +54,13 @@ import org.eclipse.jgit.storage.pack.PackWriter;
  * the connection information before invoking UploadPack.
  */
 public interface UploadPackLogger {
+       /** A simple no-op logger. */
+       public static final UploadPackLogger NULL = new UploadPackLogger() {
+               public void onPackStatistics(PackWriter.Statistics stats) {
+                       // Do nothing.
+               }
+       };
+
        /**
         * Notice to the logger after a pack has been sent.
         *