]> source.dussan.org Git - jgit.git/commitdiff
Handle null in ProgressMonitor setters 80/49980/2
authorJonathan Nieder <jrn@google.com>
Wed, 10 Jun 2015 20:59:48 +0000 (13:59 -0700)
committerJonathan Nieder <jrn@google.com>
Thu, 11 Jun 2015 17:44:20 +0000 (10:44 -0700)
These commands' monitor fields can never be null unless someone passes
null to setProgressMonitor.  Anyone passing null probably meant to
disable the ProgressMonitor, so do that (by falling back to
NullProgressMonitor.INSTANCE) instead of saving a null and eventually
producing NullPointerException.

Change-Id: I63ad93ea8ad669fd333a5fd40880e7583ba24827
Signed-off-by: Jonathan Nieder <jrn@google.com>
org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/DiffCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/PullCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java

index cd0bf33ea67f11dc73627d31da0340f279aec0fc..2b800e6c9ae853151016e9f830d540f3bca6dce6 100644 (file)
@@ -432,6 +432,9 @@ public class CloneCommand extends TransportCommand<CloneCommand, Git> {
         * @return {@code this}
         */
        public CloneCommand setProgressMonitor(ProgressMonitor monitor) {
+               if (monitor == null) {
+                       monitor = NullProgressMonitor.INSTANCE;
+               }
                this.monitor = monitor;
                return this;
        }
index 527daef811e21233e3f5e50b46013baceaa87af5..3e3a7a89c8e40c67e0cb65ab7d8bd591f4c279ac 100644 (file)
@@ -268,7 +268,10 @@ public class DiffCommand extends GitCommand<List<DiffEntry>> {
         * @return this instance
         */
        public DiffCommand setProgressMonitor(ProgressMonitor monitor) {
+               if (monitor == null) {
+                       monitor = NullProgressMonitor.INSTANCE;
+               }
                this.monitor = monitor;
                return this;
        }
-}
\ No newline at end of file
+}
index 29d475a221894d601aa062a0493f3d0d11fa49de..9620089b0848e0aeecc15d4d3cd547a1769471d9 100644 (file)
@@ -244,6 +244,9 @@ public class FetchCommand extends TransportCommand<FetchCommand, FetchResult> {
         */
        public FetchCommand setProgressMonitor(ProgressMonitor monitor) {
                checkCallable();
+               if (monitor == null) {
+                       monitor = NullProgressMonitor.INSTANCE;
+               }
                this.monitor = monitor;
                return this;
        }
index 63de85c5024469f3078ac968255af5cff018173e..2783edd5d8bf422e987d9e5a95d918f32c349e81 100644 (file)
@@ -130,6 +130,9 @@ public class PullCommand extends TransportCommand<PullCommand, PullResult> {
         * @return this instance
         */
        public PullCommand setProgressMonitor(ProgressMonitor monitor) {
+               if (monitor == null) {
+                       monitor = NullProgressMonitor.INSTANCE;
+               }
                this.monitor = monitor;
                return this;
        }
index 0e1ce58313e6fabd826ed3a876a352fc4db8f027..227e32236df670151903c9f2b3c889b75bfd65ba 100644 (file)
@@ -257,6 +257,9 @@ public class PushCommand extends
         */
        public PushCommand setProgressMonitor(ProgressMonitor monitor) {
                checkCallable();
+               if (monitor == null) {
+                       monitor = NullProgressMonitor.INSTANCE;
+               }
                this.monitor = monitor;
                return this;
        }
index 7196a2f386510aa165e30b6c5c43eb8e47f66f14..ff2900842089597890a929fde16c5e647618b869 100644 (file)
@@ -1493,6 +1493,9 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
         * @return this instance
         */
        public RebaseCommand setProgressMonitor(ProgressMonitor monitor) {
+               if (monitor == null) {
+                       monitor = NullProgressMonitor.INSTANCE;
+               }
                this.monitor = monitor;
                return this;
        }