Skip to content

Commit 4283d11

Browse files
committed
Address lint warnings.
1 parent 691538f commit 4283d11

File tree

6 files changed

+59
-9
lines changed

6 files changed

+59
-9
lines changed

appengine-java21/springboot-helloworld/src/main/java/com/example/appengine/demos/springboot/AppEngineConfig.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,14 @@
2525
/**
2626
* Declare App Engine services as Spring beans to inject them around.
2727
*
28-
* @author michaeltecourt
2928
*/
3029
@Configuration
31-
public class AppEngineConfig {
30+
public final class AppEngineConfig {
3231

32+
/**
33+
* Bean for DatastoreService.
34+
* @return an Appengine DatastoreService service.
35+
*/
3336
@Bean
3437
@ConditionalOnMissingBean
3538
public DatastoreService datastoreService() {

appengine-java21/springboot-helloworld/src/main/java/com/example/appengine/demos/springboot/HelloworldController.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,21 @@
4040
import lombok.NonNull;
4141
import lombok.extern.slf4j.Slf4j;
4242

43+
/**
44+
*
45+
* @author ludo
46+
*/
4347
@Controller
4448
@Slf4j
4549
public class HelloworldController {
4650

4751
/** Do something with the app engine datastore... */
4852
private final DatastoreService datastoreService;
4953

54+
/**
55+
*
56+
* @param datastoreService
57+
*/
5058
@Autowired
5159
public HelloworldController(DatastoreService datastoreService) {
5260
this.datastoreService = Objects.requireNonNull(datastoreService);
@@ -75,9 +83,14 @@ public AliensResponse aliens() {
7583
return AliensResponse.of(Arrays.asList(Alien.of("E.T.", "Home"), Alien.of("Marvin the Martian", "Mars")));
7684
}
7785

86+
/**
87+
* /admin endpoint handler
88+
* @param request Servlet request
89+
* @return
90+
*/
7891
@RequestMapping(value = "/admin", method = RequestMethod.GET)
7992
@ResponseBody
80-
public AliensResponse admin(HttpServletRequest request) {
93+
public AliensResponse admin(final HttpServletRequest request) {
8194
LOGGER.info("Returning the admin info...");
8295
Principal userPrincipal = request.getUserPrincipal();
8396
return AliensResponse.of(
@@ -87,7 +100,7 @@ public AliensResponse admin(HttpServletRequest request) {
87100

88101
@Data
89102
@AllArgsConstructor(staticName = "of")
90-
public static class AliensResponse {
103+
static class AliensResponse {
91104
@NonNull
92105
private final List<Alien> aliens;
93106
}
@@ -96,7 +109,7 @@ public static class AliensResponse {
96109
@AllArgsConstructor(staticName = "of")
97110
// Only used by Jackson through reflection
98111
@NoArgsConstructor(access = AccessLevel.PRIVATE, force = true)
99-
public static class Alien {
112+
static class Alien {
100113
@NonNull
101114
@NotEmpty
102115
private final String name;

appengine-java21/springboot-helloworld/src/main/java/com/example/appengine/demos/springboot/ServletInitializer.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,15 @@
1919
import org.springframework.boot.builder.SpringApplicationBuilder;
2020
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
2121

22+
/**
23+
*
24+
* Initialize the SpringBoot application.
25+
*
26+
*/
2227
public class ServletInitializer extends SpringBootServletInitializer {
2328

2429
@Override
25-
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
30+
protected SpringApplicationBuilder configure(final SpringApplicationBuilder application) {
2631
return application.sources(SpringBootExampleApplication.class);
2732
}
2833

appengine-java21/springboot-helloworld/src/main/java/com/example/appengine/demos/springboot/SpringBootExampleApplication.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,19 @@
1919
import org.springframework.boot.SpringApplication;
2020
import org.springframework.boot.autoconfigure.SpringBootApplication;
2121

22+
/**
23+
*
24+
* Main class for the application.
25+
*/
2226
@SpringBootApplication
2327
public class SpringBootExampleApplication {
2428

25-
public static void main(String[] args) {
29+
/**
30+
*
31+
* Main.
32+
* @param args for main.
33+
*/
34+
public static void main(final String[] args) {
2635
SpringApplication.run(SpringBootExampleApplication.class, args);
2736
}
2837
}

appengine-java21/springboot-helloworld/src/main/java/com/example/appengine/demos/springboot/WebAppConfiguration.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,22 @@
2727
import jakarta.servlet.ServletContextEvent;
2828
import jakarta.servlet.ServletContextListener;
2929

30+
/**
31+
*
32+
* Secure the /admin endpoints.
33+
*/
3034
@Configuration
3135
@EnableWebSecurity
3236
public class WebAppConfiguration {
37+
38+
/**
39+
* Security filter
40+
* @param http the filter HttpSecurity.
41+
* @return the next SecurityFilterChain
42+
* @throws Exception
43+
*/
3344
@Bean
34-
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
45+
public SecurityFilterChain securityFilterChain(final HttpSecurity http) throws Exception {
3546
http.authorizeHttpRequests((auth) -> auth
3647
.requestMatchers(new AntPathRequestMatcher("/admin/**")).hasRole("ADMIN")
3748
.anyRequest().permitAll()
@@ -44,6 +55,11 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
4455
return http.build();
4556
}
4657

58+
/**
59+
*
60+
* initializer of the configuration.
61+
* @return the initializer
62+
*/
4763
@Bean
4864
public ServletContextInitializer initializer() {
4965
return servletContext -> {

appengine-java21/springboot-helloworld/src/test/java/com/example/appengine/demos/springboot/SpringBootExampleApplicationTests.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
@RunWith(SpringRunner.class)
3636
@SpringBootTest(classes = SpringBootExampleApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT)
3737

38-
public class SpringBootExampleApplicationTests {
38+
class SpringBootExampleApplicationTests {
3939

4040

4141

@@ -45,6 +45,10 @@ public class SpringBootExampleApplicationTests {
4545
@Autowired
4646
private AbstractServletWebServerFactory container;
4747

48+
/**
49+
*
50+
* Make sure Jetty is used instead of Tomcat for SpringBoot.
51+
*/
4852
@Test
4953
public void applicationShouldStartWithEmbeddedJetty() {
5054
Assertions.assertThat(container).isInstanceOf(JettyServletWebServerFactory.class);

0 commit comments

Comments
 (0)