Skip to content

Commit ca5eb80

Browse files
fdeschodtfredboutin
fdeschodt
authored andcommitted
Fix for ignored exceptions (#1)
Use errors rather than exceptions, as runtime exceptions may be swallowed during initialization.
1 parent ff54a14 commit ca5eb80

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.coveo</groupId>
77
<artifactId>spring-boot-parameter-store-integration</artifactId>
8-
<version>1.0.0</version>
8+
<version>1.0.1</version>
99

1010
<name>Spring Boot Parameter Store Integration</name>
1111
<description>An integration of Amazon Web Services' Systems Manager Parameter Store for Spring Boot's properties injection.</description>

src/main/java/com/coveo/configuration/parameterstore/ParameterStoreSource.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagement;
44
import com.amazonaws.services.simplesystemsmanagement.model.GetParameterRequest;
55
import com.amazonaws.services.simplesystemsmanagement.model.ParameterNotFoundException;
6-
import com.coveo.configuration.parameterstore.exception.ParameterStoreParameterNotFoundRuntimeException;
7-
import com.coveo.configuration.parameterstore.exception.ParameterStoreRuntimeException;
6+
import com.coveo.configuration.parameterstore.exception.ParameterStoreParameterNotFoundError;
7+
import com.coveo.configuration.parameterstore.exception.ParameterStoreError;
88

99
public class ParameterStoreSource
1010
{
@@ -25,10 +25,10 @@ public Object getProperty(String propertyName)
2525
.getValue();
2626
} catch (ParameterNotFoundException e) {
2727
if (haltBoot) {
28-
throw new ParameterStoreParameterNotFoundRuntimeException(propertyName, e);
28+
throw new ParameterStoreParameterNotFoundError(propertyName, e);
2929
}
3030
} catch (Exception e) {
31-
throw new ParameterStoreRuntimeException(propertyName, e);
31+
throw new ParameterStoreError(propertyName, e);
3232
}
3333
return null;
3434
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.coveo.configuration.parameterstore.exception;
22

3-
public class ParameterStoreRuntimeException extends RuntimeException
3+
public class ParameterStoreError extends Error
44
{
55
private static final long serialVersionUID = 1L;
66

7-
public ParameterStoreRuntimeException(String propertyName, Exception e)
7+
public ParameterStoreError(String propertyName, Exception e)
88
{
99
super(String.format("Accessing Parameter Store for parameter '%s' failed.", propertyName), e);
1010
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
import com.coveo.configuration.parameterstore.ParameterStorePropertySource;
44

5-
public class ParameterStoreParameterNotFoundRuntimeException extends RuntimeException
5+
public class ParameterStoreParameterNotFoundError extends Error
66
{
77
private static final long serialVersionUID = 1L;
88

9-
public ParameterStoreParameterNotFoundRuntimeException(String propertyName, Exception e)
9+
public ParameterStoreParameterNotFoundError(String propertyName, Exception e)
1010
{
1111
super(String.format("Properties prefixed with a '%s' are reserved for the AWS Parameter Store. "
1212
+ "The property '%s' was not found in it. "

src/test/java/com/coveo/configuration/parameterstore/ParameterStoreSourceTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
import com.amazonaws.services.simplesystemsmanagement.model.GetParameterResult;
1616
import com.amazonaws.services.simplesystemsmanagement.model.Parameter;
1717
import com.amazonaws.services.simplesystemsmanagement.model.ParameterNotFoundException;
18-
import com.coveo.configuration.parameterstore.exception.ParameterStoreParameterNotFoundRuntimeException;
19-
import com.coveo.configuration.parameterstore.exception.ParameterStoreRuntimeException;
18+
import com.coveo.configuration.parameterstore.exception.ParameterStoreError;
19+
import com.coveo.configuration.parameterstore.exception.ParameterStoreParameterNotFoundError;
2020

2121
@RunWith(MockitoJUnitRunner.class)
2222
public class ParameterStoreSourceTest
@@ -57,15 +57,15 @@ public void testGetPropertyWhenNotFoundReturnsNull()
5757
assertThat(value, is(nullValue()));
5858
}
5959

60-
@Test(expected = ParameterStoreRuntimeException.class)
60+
@Test(expected = ParameterStoreError.class)
6161
public void shouldThrowOnUnexpectedExceptionAccessingParameterStore()
6262
{
6363
when(ssmClientMock.getParameter(getParameterRequest(VALID_PROPERTY_NAME))).thenThrow(new RuntimeException());
6464

6565
parameterStoreSource.getProperty(VALID_PROPERTY_NAME);
6666
}
6767

68-
@Test(expected = ParameterStoreParameterNotFoundRuntimeException.class)
68+
@Test(expected = ParameterStoreParameterNotFoundError.class)
6969
public void shouldThrowOnGetPropertyWhenNotFoundAndHaltBootIsTrue()
7070
{
7171
when(ssmClientMock.getParameter(getParameterRequest(INVALID_PROPERTY_NAME))).thenThrow(new ParameterNotFoundException(""));

0 commit comments

Comments
 (0)