Skip to content

Commit

Permalink
replaced NullPointerException with IllegalArgumentException
Browse files Browse the repository at this point in the history
  • Loading branch information
Luigi R. Viggiano committed Oct 10, 2013
1 parent d0b66c8 commit 729ad7f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/aeonbits/owner/DefaultFactory.java
Expand Up @@ -52,7 +52,7 @@ public String setProperty(String key, String value) {

private void checkKey(String key) {
if (key == null)
throw new NullPointerException("key can't be null");
throw new IllegalArgumentException("key can't be null");
if (key.isEmpty())
throw new IllegalArgumentException("key can't be empty");
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/aeonbits/owner/LoadersManager.java
Expand Up @@ -66,7 +66,7 @@ Loader findLoader(URL url) {

final void registerLoader(Loader loader) {
if (loader == null)
throw new NullPointerException("loader can't be null");
throw new IllegalArgumentException("loader can't be null");
lock.writeLock().lock();
try {
loaders.add(0, loader);
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/org/aeonbits/owner/ConfigFactoryTest.java
Expand Up @@ -52,7 +52,7 @@ public void testSetProperty() {
assertEquals("foobar", cfg.someValue());
}

@Test(expected = NullPointerException.class)
@Test(expected = IllegalArgumentException.class)
public void testSetPropertyNullKey() {
ConfigFactory.setProperty(null, "foobar");
}
Expand Down Expand Up @@ -104,7 +104,7 @@ public void testGetProperty() {
assertEquals(RESOURCES_DIR, ConfigFactory.getProperty("mypath"));
}

@Test(expected = NullPointerException.class)
@Test(expected = IllegalArgumentException.class)
public void testGetPropertyNullKey() {
ConfigFactory.getProperty(null);
}
Expand All @@ -121,7 +121,7 @@ public void testGetClearProperty() {
assertNull(ConfigFactory.getProperty("mypath"));
}

@Test(expected = NullPointerException.class)
@Test(expected = IllegalArgumentException.class)
public void testClearPropertyNullKey() {
ConfigFactory.clearProperty(null);
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/aeonbits/owner/LoaderManagerTest.java
Expand Up @@ -111,13 +111,13 @@ public String defaultSpecFor(String urlPrefix) {
assertEquals("bar", cfg.foo());
}

@Test(expected = NullPointerException.class)
@Test(expected = IllegalArgumentException.class)
public void testRegisterNull() {
Factory factory = ConfigFactory.newInstance();
factory.registerLoader(null);
}

@Test(expected = NullPointerException.class)
@Test(expected = IllegalArgumentException.class)
public void testRegisterNullOnSingleton() {
ConfigFactory.registerLoader(null);
}
Expand Down

0 comments on commit 729ad7f

Please sign in to comment.