Skip to content

Commit 7fb16fa

Browse files
committed
Ignore not found error
1 parent d11160d commit 7fb16fa

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

src/main/java/org/mybatis/scripting/thymeleaf/ThymeleafLanguageDriverConfig.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ public static ThymeleafLanguageDriverConfig newInstance() {
300300
*/
301301
public static ThymeleafLanguageDriverConfig newInstance(String resourcePath) {
302302
Properties properties = loadDefaultProperties();
303-
properties.putAll(loadProperties(resourcePath, false));
303+
properties.putAll(loadProperties(resourcePath));
304304
return newInstance(properties);
305305
}
306306

@@ -345,20 +345,16 @@ private static void override(ThymeleafLanguageDriverConfig config, Properties pr
345345
}
346346

347347
private static Properties loadDefaultProperties() {
348-
return loadProperties(System.getProperty(PROPERTY_KEY_CONFIG_FILE, DEFAULT_PROPERTIES_FILE), true);
348+
return loadProperties(System.getProperty(PROPERTY_KEY_CONFIG_FILE, DEFAULT_PROPERTIES_FILE));
349349
}
350350

351-
private static Properties loadProperties(String resourcePath, boolean ignoreNotFound) {
351+
private static Properties loadProperties(String resourcePath) {
352352
Properties properties = new Properties();
353353
InputStream in;
354354
try {
355355
in = Resources.getResourceAsStream(resourcePath);
356356
} catch (IOException e) {
357-
if (ignoreNotFound) {
358357
in = null;
359-
} else {
360-
throw new UncheckedIOException(e);
361-
}
362358
}
363359
if (in != null) {
364360
Charset encoding = Optional.ofNullable(System.getProperty(PROPERTY_KEY_CONFIG_ENCODING))

src/test/java/org/mybatis/scripting/thymeleaf/ThymeleafLanguageDriverTest.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -323,12 +323,10 @@ void testConfigFileNotFound() {
323323

324324
@Test
325325
void testConfigFileNotFoundAtMethodArgument() {
326-
try {
327-
ThymeleafLanguageDriverConfig.newInstance("mybatis-thymeleaf-dummy.properties");
328-
Assertions.fail();
329-
} catch (UncheckedIOException e) {
330-
Assertions.assertEquals("java.io.IOException: Could not find resource mybatis-thymeleaf-dummy.properties", e.getMessage());
331-
}
326+
ThymeleafLanguageDriverConfig.newInstance("mybatis-thymeleaf-dummy.properties");
327+
Configuration configuration = new Configuration();
328+
configuration.setDefaultScriptingLanguage(ThymeleafLanguageDriver.class);
329+
Assertions.assertEquals(ThymeleafLanguageDriver.class, configuration.getLanguageRegistry().getDefaultDriverClass());
332330
}
333331

334332
@Test

0 commit comments

Comments
 (0)