Mini articles/java unknown stack trace (#11627)
* unknown source in stack trace * Improved comment * creating an intentional exception Co-authored-by: Sameer <d7495b5879fca1ec1367476a5395a60a8e9baec9>
This commit is contained in:
parent
5a5714b9f6
commit
7d4fd180d8
@ -24,6 +24,22 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.1</version>
|
||||||
|
<configuration>
|
||||||
|
<compilerArgs>
|
||||||
|
<!-- Comment the arg below to print complete stack trace information -->
|
||||||
|
<!-- <arg>-g:none</arg>-->
|
||||||
|
</compilerArgs>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<h2.version>1.4.191</h2.version>
|
<h2.version>1.4.191</h2.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
package com.baeldung.unknownsourcestacktrace;
|
||||||
|
|
||||||
|
import com.baeldung.unknownsourcestacktrace.dto.User;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
public class Main {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(Main.class);
|
||||||
|
private static final int SHORT_NAME_LIMIT = 10;
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
User user = new User();
|
||||||
|
user.setName("Tom");
|
||||||
|
|
||||||
|
logger.info(getGreetingMessage(user.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getGreetingMessage(String name) {
|
||||||
|
return "Welcome " + getShortenedName(name) + "!";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getShortenedName(String name) {
|
||||||
|
return name.substring(0, SHORT_NAME_LIMIT);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.baeldung.unknownsourcestacktrace.dto;
|
||||||
|
|
||||||
|
public class User {
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user