This repository was archived by the owner on Jun 4, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +26
-2
lines changed
main/java/uk/bot_by/aws_lambda/slf4j
test/java/uk/bot_by/aws_lambda/slf4j Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 1414# KIND, either express or implied. See the License for the
1515# specific language governing permissions and limitations
1616# under the License.
17- distributionUrl =https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6 /apache-maven-3.8.6 -bin.zip
17+ distributionUrl =https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7 /apache-maven-3.8.7 -bin.zip
1818wrapperUrl =https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar
Original file line number Diff line number Diff line change @@ -278,7 +278,7 @@ private Properties loadProperties(String configurationFile) {
278278 try (InputStream configurationInputStream = Thread .currentThread ().getContextClassLoader ()
279279 .getResourceAsStream (configurationFile )) {
280280 properties .load (configurationInputStream );
281- } catch (IOException e ) {
281+ } catch (IOException | NullPointerException e ) {
282282 // ignored
283283 }
284284
Original file line number Diff line number Diff line change @@ -305,4 +305,28 @@ void useLoggerProperties() {
305305 "properties-request-id \\ d{2}:\\ d{2}:\\ d{2}\\ .\\ d{3} \\ [main\\ ] thread=1 \\ [DEBUG\\ ] test - debug message[\\ n\\ r]+" ));
306306 }
307307
308+ @ DisplayName ("Try to read missed logger properties file, use default values" )
309+ @ Test
310+ void missedProperties () {
311+ // given
312+ var loggerFactory = spy (new LambdaLoggerFactory ("missed.properties" ));
313+
314+ doReturn (printStream ).when (loggerFactory ).getPrintStream ();
315+
316+ MDC .put ("request#" , "properties-request-id" );
317+
318+ // when
319+ var logger = loggerFactory .getLogger ("lambda.logger.test" );
320+
321+ logger .debug ("debug message" );
322+ logger .info ("info message" );
323+
324+ // then
325+ printStream .flush ();
326+ printStream .close ();
327+ outputStream .toString (StandardCharsets .UTF_8 );
328+ assertThat (outputStream .toString (StandardCharsets .UTF_8 ), matchesPattern (
329+ "INFO lambda.logger.test - info message[\\ n\\ r]+" ));
330+ }
331+
308332}
You can’t perform that action at this time.
0 commit comments