Merge "DefaultTypedConfigGetter: Box values to avoid infinite recursion"
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/DefaultTypedConfigGetter.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/DefaultTypedConfigGetter.java
index 6509398..3059f28 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/DefaultTypedConfigGetter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/DefaultTypedConfigGetter.java
@@ -32,10 +32,12 @@
  */
 public class DefaultTypedConfigGetter implements TypedConfigGetter {
 
+	@SuppressWarnings("boxed")
 	@Override
 	public boolean getBoolean(Config config, String section, String subsection,
 			String name, boolean defaultValue) {
-		return getBoolean(config, section, subsection, name, defaultValue);
+		return neverNull(getBoolean(config, section, subsection, name,
+				Boolean.valueOf(defaultValue)));
 	}
 
 	@Nullable
@@ -116,7 +118,8 @@ public <T extends Enum<?>> T getEnum(Config config, T[] all, String section,
 	@Override
 	public int getInt(Config config, String section, String subsection,
 			String name, int defaultValue) {
-		return getInt(config, section, subsection, name, defaultValue);
+		return neverNull(getInt(config, section, subsection, name,
+				Integer.valueOf(defaultValue)));
 	}
 
 	@Nullable
@@ -144,8 +147,8 @@ public Integer getInt(Config config, String section, String subsection,
 	@Override
 	public int getIntInRange(Config config, String section, String subsection,
 			String name, int minValue, int maxValue, int defaultValue) {
-		return getIntInRange(config, section, subsection, name, minValue,
-				maxValue, defaultValue);
+		return neverNull(getIntInRange(config, section, subsection, name,
+				minValue, maxValue, Integer.valueOf(defaultValue)));
 	}
 
 	@Override
@@ -161,9 +164,9 @@ public Integer getIntInRange(Config config, String section,
 			return val;
 		}
 		if (subsection == null) {
-			throw new IllegalArgumentException(MessageFormat.format(
-					JGitText.get().integerValueNotInRange, section, name,
-					val, minValue, maxValue));
+			throw new IllegalArgumentException(
+					MessageFormat.format(JGitText.get().integerValueNotInRange,
+							section, name, val, minValue, maxValue));
 		}
 		throw new IllegalArgumentException(MessageFormat.format(
 				JGitText.get().integerValueNotInRangeSubSection, section,
@@ -173,7 +176,8 @@ public Integer getIntInRange(Config config, String section,
 	@Override
 	public long getLong(Config config, String section, String subsection,
 			String name, long defaultValue) {
-		return getLong(config, section, subsection, name, defaultValue);
+		return neverNull(getLong(config, section, subsection, name,
+				Long.valueOf(defaultValue)));
 	}
 
 	@Nullable
@@ -190,8 +194,9 @@ public Long getLong(Config config, String section, String subsection,
 			// Empty
 			return defaultValue;
 		} catch (NumberFormatException nfe) {
-			throw new IllegalArgumentException(MessageFormat.format(
-					JGitText.get().invalidIntegerValue, section, name, str),
+			throw new IllegalArgumentException(
+					MessageFormat.format(JGitText.get().invalidIntegerValue,
+							section, name, str),
 					nfe);
 		}
 	}
@@ -199,9 +204,8 @@ public Long getLong(Config config, String section, String subsection,
 	@Override
 	public long getTimeUnit(Config config, String section, String subsection,
 			String name, long defaultValue, TimeUnit wantUnit) {
-		Long v = getTimeUnit(config, section, subsection, name,
-				Long.valueOf(defaultValue), wantUnit);
-		return v == null ? defaultValue : v.longValue();
+		return neverNull(getTimeUnit(config, section, subsection, name,
+				Long.valueOf(defaultValue), wantUnit));
 	}
 
 	@Override
@@ -325,4 +329,14 @@ public List<RefSpec> getRefSpecs(Config config, String section,
 		}
 		return result;
 	}
+
+	// Trick for the checkers. When we use this, one is never null, but
+	// they don't know.
+	@NonNull
+	private static <T> T neverNull(T one) {
+		if (one == null) {
+			throw new IllegalArgumentException();
+		}
+		return one;
+	}
 }