Skip to content

Commit 25346ee

Browse files
authored
Fix uncaught UnsupportedOperationException
2 parents f56ed5e + c9cca5f commit 25346ee

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

dockerfile-image-update/src/main/java/com/salesforce/dockerfileimageupdate/process/ForkableRepoValidator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ protected boolean hasNoChanges(GHContent content, GitForkBranch gitForkBranch) {
108108
return false;
109109
}
110110
}
111-
} catch (IOException exception) {
111+
} catch (IOException | UnsupportedOperationException exception) {
112112
log.warn("Failed while checking if there are changes in {}. Skipping... exception: {}",
113-
content.getPath(), exception.getMessage());
113+
content.getPath(), exception.getMessage(), exception);
114114
}
115115
return true;
116116
}

dockerfile-image-update/src/test/java/com/salesforce/dockerfileimageupdate/process/ForkableRepoValidatorTest.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public void testHasNoChanges(String contentText, String imageName, String imageT
232232
}
233233

234234
@Test
235-
public void testHasNoChangesIfExceptionThrownDuringRead() throws IOException {
235+
public void testHasNoChangesIfIOExceptionThrownDuringRead() throws IOException {
236236
DockerfileGitHubUtil dockerfileGitHubUtil = mock(DockerfileGitHubUtil.class);
237237
GHRepository repo = mock(GHRepository.class);
238238
ForkableRepoValidator validator = new ForkableRepoValidator(dockerfileGitHubUtil);
@@ -243,4 +243,17 @@ public void testHasNoChangesIfExceptionThrownDuringRead() throws IOException {
243243

244244
assertTrue(validator.hasNoChanges(content, gitForkBranch));
245245
}
246+
247+
@Test
248+
public void testHasNoChangesIfUnsupportedOperationExceptionThrownDuringRead() throws IOException {
249+
DockerfileGitHubUtil dockerfileGitHubUtil = mock(DockerfileGitHubUtil.class);
250+
GHRepository repo = mock(GHRepository.class);
251+
ForkableRepoValidator validator = new ForkableRepoValidator(dockerfileGitHubUtil);
252+
GHContent content = mock(GHContent.class);
253+
GitForkBranch gitForkBranch = new GitForkBranch("name", "tag", null, "");
254+
255+
when(content.read()).thenThrow(new UnsupportedOperationException("Unrecognized encoding: none"));
256+
257+
assertTrue(validator.hasNoChanges(content, gitForkBranch));
258+
}
246259
}

0 commit comments

Comments
 (0)