diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfiguration.java
index af610464506..c8ffa1ffbee 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfiguration.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfiguration.java
@@ -237,8 +237,9 @@ public class JerseyAutoConfiguration implements ServletContextAware {
final ObjectMapper objectMapper) {
addJaxbAnnotationIntrospectorIfPresent(objectMapper);
return (ResourceConfig config) -> {
- config.register(JacksonFeature.class);
- config.register(new ObjectMapperContextResolver(objectMapper),
+ JerseyAutoConfiguration.this.config.register(JacksonFeature.class);
+ JerseyAutoConfiguration.this.config.register(
+ new ObjectMapperContextResolver(objectMapper),
ContextResolver.class);
};
}
diff --git a/spring-boot-project/spring-boot-parent/src/checkstyle/checkstyle-suppressions.xml b/spring-boot-project/spring-boot-parent/src/checkstyle/checkstyle-suppressions.xml
index bc589ec0daa..180e5936952 100644
--- a/spring-boot-project/spring-boot-parent/src/checkstyle/checkstyle-suppressions.xml
+++ b/spring-boot-project/spring-boot-parent/src/checkstyle/checkstyle-suppressions.xml
@@ -5,8 +5,7 @@
-
-
+
@@ -23,4 +22,8 @@
+
+
+
+
diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/ZipCompression.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/ZipCompression.java
index 4e972fd8eb0..ecf23cc61d7 100644
--- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/ZipCompression.java
+++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/ZipCompression.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2017 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-boot-samples/spring-boot-sample-ant/src/test/java/sample/ant/SampleAntApplicationIT.java b/spring-boot-samples/spring-boot-sample-ant/src/test/java/sample/ant/SampleAntApplicationIT.java
index 2546037cb2e..f98932029aa 100644
--- a/spring-boot-samples/spring-boot-sample-ant/src/test/java/sample/ant/SampleAntApplicationIT.java
+++ b/spring-boot-samples/spring-boot-sample-ant/src/test/java/sample/ant/SampleAntApplicationIT.java
@@ -16,17 +16,18 @@
package sample.ant;
-import static org.assertj.core.api.Assertions.assertThat;
-
import java.io.File;
import java.io.FileFilter;
import java.io.InputStreamReader;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
+
import org.springframework.boot.loader.tools.JavaExecutable;
import org.springframework.util.FileCopyUtils;
+import static org.assertj.core.api.Assertions.assertThat;
+
/**
* Integration Tests for {@code SampleAntApplication}.
*
diff --git a/spring-boot-samples/spring-boot-sample-ant/src/test/resources/application.properties b/spring-boot-samples/spring-boot-sample-ant/src/test/resources/application.properties
index 4dfe84cedc6..b04cdc39b58 100644
--- a/spring-boot-samples/spring-boot-sample-ant/src/test/resources/application.properties
+++ b/spring-boot-samples/spring-boot-sample-ant/src/test/resources/application.properties
@@ -1 +1 @@
-name: Phil
\ No newline at end of file
+name: Phil
diff --git a/spring-boot-samples/spring-boot-sample-aop/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-aop/src/main/resources/application.properties
index 4dfe84cedc6..b04cdc39b58 100644
--- a/spring-boot-samples/spring-boot-sample-aop/src/main/resources/application.properties
+++ b/spring-boot-samples/spring-boot-sample-aop/src/main/resources/application.properties
@@ -1 +1 @@
-name: Phil
\ No newline at end of file
+name: Phil
diff --git a/spring-boot-samples/spring-boot-sample-atmosphere/src/main/java/sample/atmosphere/SampleAtmosphereApplication.java b/spring-boot-samples/spring-boot-sample-atmosphere/src/main/java/sample/atmosphere/SampleAtmosphereApplication.java
index 892d9327a83..4f6800bef0e 100644
--- a/spring-boot-samples/spring-boot-sample-atmosphere/src/main/java/sample/atmosphere/SampleAtmosphereApplication.java
+++ b/spring-boot-samples/spring-boot-sample-atmosphere/src/main/java/sample/atmosphere/SampleAtmosphereApplication.java
@@ -59,6 +59,10 @@ public class SampleAtmosphereApplication {
return registration;
}
+ public static void main(String[] args) throws Exception {
+ SpringApplication.run(SampleAtmosphereApplication.class, args);
+ }
+
@Configuration
static class MvcConfiguration implements WebMvcConfigurer {
@@ -79,8 +83,4 @@ public class SampleAtmosphereApplication {
}
- public static void main(String[] args) {
- SpringApplication.run(SampleAtmosphereApplication.class, args);
- }
-
}
diff --git a/spring-boot-samples/spring-boot-sample-cache/src/main/java/sample/cache/SampleClient.java b/spring-boot-samples/spring-boot-sample-cache/src/main/java/sample/cache/SampleClient.java
index b3c27a3a4ff..8703725c553 100644
--- a/spring-boot-samples/spring-boot-sample-cache/src/main/java/sample/cache/SampleClient.java
+++ b/spring-boot-samples/spring-boot-sample-cache/src/main/java/sample/cache/SampleClient.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2016 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -53,7 +53,7 @@ class SampleClient {
private final Random random;
- public SampleClient(CountryRepository countryService) {
+ SampleClient(CountryRepository countryService) {
this.countryService = countryService;
this.random = new Random();
}
diff --git a/spring-boot-samples/spring-boot-sample-custom-layout/src/main/java/sample/layout/SampleLayout.java b/spring-boot-samples/spring-boot-sample-custom-layout/src/main/java/sample/layout/SampleLayout.java
index 0965c787b45..8c9b8b729f9 100644
--- a/spring-boot-samples/spring-boot-sample-custom-layout/src/main/java/sample/layout/SampleLayout.java
+++ b/spring-boot-samples/spring-boot-sample-custom-layout/src/main/java/sample/layout/SampleLayout.java
@@ -24,6 +24,8 @@ import org.springframework.boot.loader.tools.Layouts;
import org.springframework.boot.loader.tools.LoaderClassesWriter;
/**
+ * An example layout.
+ *
* @author Phillip Webb
*/
public class SampleLayout extends Layouts.Jar implements CustomLoaderLayout {
diff --git a/spring-boot-samples/spring-boot-sample-data-cassandra/src/main/java/sample/data/cassandra/CustomerRepository.java b/spring-boot-samples/spring-boot-sample-data-cassandra/src/main/java/sample/data/cassandra/CustomerRepository.java
index 55eb59c4563..8c4b317d8e8 100644
--- a/spring-boot-samples/spring-boot-sample-data-cassandra/src/main/java/sample/data/cassandra/CustomerRepository.java
+++ b/spring-boot-samples/spring-boot-sample-data-cassandra/src/main/java/sample/data/cassandra/CustomerRepository.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2013 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,9 +24,9 @@ import org.springframework.data.repository.CrudRepository;
public interface CustomerRepository extends CrudRepository {
@Query("Select * from customer where firstname=?0")
- public Customer findByFirstName(String firstName);
+ Customer findByFirstName(String firstName);
@Query("Select * from customer where lastname=?0")
- public List findByLastName(String lastName);
+ List findByLastName(String lastName);
}
diff --git a/spring-boot-samples/spring-boot-sample-data-elasticsearch/src/main/java/sample/data/elasticsearch/CustomerRepository.java b/spring-boot-samples/spring-boot-sample-data-elasticsearch/src/main/java/sample/data/elasticsearch/CustomerRepository.java
index 295768e7ec8..7c95b50a46d 100644
--- a/spring-boot-samples/spring-boot-sample-data-elasticsearch/src/main/java/sample/data/elasticsearch/CustomerRepository.java
+++ b/spring-boot-samples/spring-boot-sample-data-elasticsearch/src/main/java/sample/data/elasticsearch/CustomerRepository.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2013 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,8 +22,8 @@ import org.springframework.data.elasticsearch.repository.ElasticsearchRepository
public interface CustomerRepository extends ElasticsearchRepository {
- public Customer findByFirstName(String firstName);
+ Customer findByFirstName(String firstName);
- public List findByLastName(String lastName);
+ List findByLastName(String lastName);
}
diff --git a/spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/service/CityServiceImpl.java b/spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/service/CityServiceImpl.java
index 51884556a74..6e57098b4ad 100644
--- a/spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/service/CityServiceImpl.java
+++ b/spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/service/CityServiceImpl.java
@@ -34,8 +34,7 @@ class CityServiceImpl implements CityService {
private final HotelRepository hotelRepository;
- public CityServiceImpl(CityRepository cityRepository,
- HotelRepository hotelRepository) {
+ CityServiceImpl(CityRepository cityRepository, HotelRepository hotelRepository) {
this.cityRepository = cityRepository;
this.hotelRepository = hotelRepository;
}
diff --git a/spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/service/HotelServiceImpl.java b/spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/service/HotelServiceImpl.java
index 327919ce13c..0969ca601ee 100644
--- a/spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/service/HotelServiceImpl.java
+++ b/spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/service/HotelServiceImpl.java
@@ -41,8 +41,7 @@ class HotelServiceImpl implements HotelService {
private final ReviewRepository reviewRepository;
- public HotelServiceImpl(HotelRepository hotelRepository,
- ReviewRepository reviewRepository) {
+ HotelServiceImpl(HotelRepository hotelRepository, ReviewRepository reviewRepository) {
this.hotelRepository = hotelRepository;
this.reviewRepository = reviewRepository;
}
@@ -82,7 +81,7 @@ class HotelServiceImpl implements HotelService {
private final Map ratingCount;
- public ReviewsSummaryImpl(List ratingCounts) {
+ ReviewsSummaryImpl(List ratingCounts) {
this.ratingCount = new HashMap<>();
for (RatingCount ratingCount : ratingCounts) {
this.ratingCount.put(ratingCount.getRating(), ratingCount.getCount());
@@ -92,7 +91,7 @@ class HotelServiceImpl implements HotelService {
@Override
public long getNumberOfReviewsWithRating(Rating rating) {
Long count = this.ratingCount.get(rating);
- return count == null ? 0 : count;
+ return (count != null ? count : 0);
}
}
diff --git a/spring-boot-samples/spring-boot-sample-data-jpa/src/test/resources/application-scratch.properties b/spring-boot-samples/spring-boot-sample-data-jpa/src/test/resources/application-scratch.properties
index 782bef1f1a4..151dd486c17 100644
--- a/spring-boot-samples/spring-boot-sample-data-jpa/src/test/resources/application-scratch.properties
+++ b/spring-boot-samples/spring-boot-sample-data-jpa/src/test/resources/application-scratch.properties
@@ -1,2 +1,2 @@
spring.datasource.name=scratchdb
-spring.jmx.default-domain=jpa.sample
\ No newline at end of file
+spring.jmx.default-domain=jpa.sample
diff --git a/spring-boot-samples/spring-boot-sample-data-mongodb/src/main/java/sample/data/mongo/Customer.java b/spring-boot-samples/spring-boot-sample-data-mongodb/src/main/java/sample/data/mongo/Customer.java
index 09ba965ee2b..f701e363686 100644
--- a/spring-boot-samples/spring-boot-sample-data-mongodb/src/main/java/sample/data/mongo/Customer.java
+++ b/spring-boot-samples/spring-boot-sample-data-mongodb/src/main/java/sample/data/mongo/Customer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2013 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@ public class Customer {
private String id;
private String firstName;
+
private String lastName;
public Customer() {
@@ -36,8 +37,8 @@ public class Customer {
@Override
public String toString() {
- return String.format("Customer[id=%s, firstName='%s', lastName='%s']", id,
- firstName, lastName);
+ return String.format("Customer[id=%s, firstName='%s', lastName='%s']", this.id,
+ this.firstName, this.lastName);
}
}
diff --git a/spring-boot-samples/spring-boot-sample-data-mongodb/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-data-mongodb/src/main/resources/application.properties
deleted file mode 100644
index e69de29bb2d..00000000000
diff --git a/spring-boot-samples/spring-boot-sample-data-neo4j/src/main/java/sample/data/neo4j/Customer.java b/spring-boot-samples/spring-boot-sample-data-neo4j/src/main/java/sample/data/neo4j/Customer.java
index be5551cbaa3..797880429e5 100644
--- a/spring-boot-samples/spring-boot-sample-data-neo4j/src/main/java/sample/data/neo4j/Customer.java
+++ b/spring-boot-samples/spring-boot-sample-data-neo4j/src/main/java/sample/data/neo4j/Customer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2017 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,6 +28,7 @@ public class Customer {
private Long id;
private String firstName;
+
private String lastName;
public Customer() {
diff --git a/spring-boot-samples/spring-boot-sample-data-neo4j/src/main/java/sample/data/neo4j/CustomerRepository.java b/spring-boot-samples/spring-boot-sample-data-neo4j/src/main/java/sample/data/neo4j/CustomerRepository.java
index 518b991decc..38f10e42e08 100644
--- a/spring-boot-samples/spring-boot-sample-data-neo4j/src/main/java/sample/data/neo4j/CustomerRepository.java
+++ b/spring-boot-samples/spring-boot-sample-data-neo4j/src/main/java/sample/data/neo4j/CustomerRepository.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2017 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,8 +22,8 @@ import org.springframework.data.neo4j.repository.Neo4jRepository;
public interface CustomerRepository extends Neo4jRepository {
- public Customer findByFirstName(String firstName);
+ Customer findByFirstName(String firstName);
- public List findByLastName(String lastName);
+ List findByLastName(String lastName);
}
diff --git a/spring-boot-samples/spring-boot-sample-data-neo4j/src/test/java/sample/data/neo4j/SampleNeo4jApplicationTests.java b/spring-boot-samples/spring-boot-sample-data-neo4j/src/test/java/sample/data/neo4j/SampleNeo4jApplicationTests.java
index 852ee2b9282..117d6142c55 100644
--- a/spring-boot-samples/spring-boot-sample-data-neo4j/src/test/java/sample/data/neo4j/SampleNeo4jApplicationTests.java
+++ b/spring-boot-samples/spring-boot-sample-data-neo4j/src/test/java/sample/data/neo4j/SampleNeo4jApplicationTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2017 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@ import org.neo4j.driver.v1.exceptions.ServiceUnavailableException;
import org.springframework.boot.test.rule.OutputCapture;
-import static org.junit.Assert.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link SampleNeo4jApplication}.
@@ -45,8 +45,7 @@ public class SampleNeo4jApplicationTests {
}
}
String output = this.outputCapture.toString();
- assertTrue("Wrong output: " + output,
- output.contains("firstName='Alice', lastName='Smith'"));
+ assertThat(output).contains("firstName='Alice', lastName='Smith'");
}
private boolean neo4jServerRunning(Throwable ex) {
diff --git a/spring-boot-samples/spring-boot-sample-data-rest/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-data-rest/src/main/resources/application.properties
index d329a65ebd1..6846da4e638 100644
--- a/spring-boot-samples/spring-boot-sample-data-rest/src/main/resources/application.properties
+++ b/spring-boot-samples/spring-boot-sample-data-rest/src/main/resources/application.properties
@@ -1 +1 @@
-spring.data.rest.base-path=/api
\ No newline at end of file
+spring.data.rest.base-path=/api
diff --git a/spring-boot-samples/spring-boot-sample-devtools/src/main/java/sample/devtools/Message.java b/spring-boot-samples/spring-boot-sample-devtools/src/main/java/sample/devtools/Message.java
index ea16b5c1364..24340365ed3 100644
--- a/spring-boot-samples/spring-boot-sample-devtools/src/main/java/sample/devtools/Message.java
+++ b/spring-boot-samples/spring-boot-sample-devtools/src/main/java/sample/devtools/Message.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2015 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,8 +16,14 @@
package sample.devtools;
-public class Message {
+public final class Message {
+ /**
+ * Sample message.
+ */
public static String MESSAGE = "Message";
+ private Message() {
+ }
+
}
diff --git a/spring-boot-samples/spring-boot-sample-flyway/src/main/java/sample/flyway/Person.java b/spring-boot-samples/spring-boot-sample-flyway/src/main/java/sample/flyway/Person.java
index a304be08437..ca27af4909f 100644
--- a/spring-boot-samples/spring-boot-sample-flyway/src/main/java/sample/flyway/Person.java
+++ b/spring-boot-samples/spring-boot-sample-flyway/src/main/java/sample/flyway/Person.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2017 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,11 +23,14 @@ import javax.persistence.SequenceGenerator;
@Entity
public class Person {
+
@Id
@SequenceGenerator(name = "person_generator", sequenceName = "person_sequence", allocationSize = 1)
@GeneratedValue(generator = "person_generator")
private Long id;
+
private String firstName;
+
private String lastName;
public String getFirstName() {
@@ -51,4 +54,5 @@ public class Person {
return "Person [firstName=" + this.firstName + ", lastName=" + this.lastName
+ "]";
}
+
}
diff --git a/spring-boot-samples/spring-boot-sample-integration/src/test/java/sample/integration/consumer/SampleIntegrationApplicationTests.java b/spring-boot-samples/spring-boot-sample-integration/src/test/java/sample/integration/consumer/SampleIntegrationApplicationTests.java
index 85d9efd430b..904e3d29180 100644
--- a/spring-boot-samples/spring-boot-sample-integration/src/test/java/sample/integration/consumer/SampleIntegrationApplicationTests.java
+++ b/spring-boot-samples/spring-boot-sample-integration/src/test/java/sample/integration/consumer/SampleIntegrationApplicationTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2017 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -119,4 +119,5 @@ public class SampleIntegrationApplicationTests {
}
return candidates;
}
+
}
diff --git a/spring-boot-samples/spring-boot-sample-jersey1/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-jersey1/src/main/resources/application.properties
deleted file mode 100644
index e69de29bb2d..00000000000
diff --git a/spring-boot-samples/spring-boot-sample-jetty-ssl/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-jetty-ssl/src/main/resources/application.properties
index 953abe0d6c9..37199bfd256 100644
--- a/spring-boot-samples/spring-boot-sample-jetty-ssl/src/main/resources/application.properties
+++ b/spring-boot-samples/spring-boot-sample-jetty-ssl/src/main/resources/application.properties
@@ -1,4 +1,4 @@
server.port = 8443
server.ssl.key-store = classpath:sample.jks
server.ssl.key-store-password = secret
-server.ssl.key-password = password
\ No newline at end of file
+server.ssl.key-password = password
diff --git a/spring-boot-samples/spring-boot-sample-jooq/src/main/java/sample/jooq/JooqExamples.java b/spring-boot-samples/spring-boot-sample-jooq/src/main/java/sample/jooq/JooqExamples.java
index 2b6f355741a..8fa117f97e8 100644
--- a/spring-boot-samples/spring-boot-sample-jooq/src/main/java/sample/jooq/JooqExamples.java
+++ b/spring-boot-samples/spring-boot-sample-jooq/src/main/java/sample/jooq/JooqExamples.java
@@ -76,4 +76,5 @@ public class JooqExamples implements CommandLineRunner {
});
System.out.println("jOOQ SQL " + list);
}
+
}
diff --git a/spring-boot-samples/spring-boot-sample-liquibase/src/test/java/sample/liquibase/SampleLiquibaseApplicationTests.java b/spring-boot-samples/spring-boot-sample-liquibase/src/test/java/sample/liquibase/SampleLiquibaseApplicationTests.java
index 2e490bc0dac..8759c386889 100644
--- a/spring-boot-samples/spring-boot-sample-liquibase/src/test/java/sample/liquibase/SampleLiquibaseApplicationTests.java
+++ b/spring-boot-samples/spring-boot-sample-liquibase/src/test/java/sample/liquibase/SampleLiquibaseApplicationTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2016 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -68,4 +68,5 @@ public class SampleLiquibaseApplicationTests {
}
return false;
}
+
}
diff --git a/spring-boot-samples/spring-boot-sample-oauth2-client/src/main/java/sample/oauth2/client/SampleOAuth2ClientApplication.java b/spring-boot-samples/spring-boot-sample-oauth2-client/src/main/java/sample/oauth2/client/SampleOAuth2ClientApplication.java
index d24193366e1..1deffbee0e1 100644
--- a/spring-boot-samples/spring-boot-sample-oauth2-client/src/main/java/sample/oauth2/client/SampleOAuth2ClientApplication.java
+++ b/spring-boot-samples/spring-boot-sample-oauth2-client/src/main/java/sample/oauth2/client/SampleOAuth2ClientApplication.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2017 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-boot-samples/spring-boot-sample-oauth2-client/src/test/java/sample/oauth2/client/SampleOAuth2ClientApplicationTests.java b/spring-boot-samples/spring-boot-sample-oauth2-client/src/test/java/sample/oauth2/client/SampleOAuth2ClientApplicationTests.java
index 3091408f244..52ef0cd3197 100644
--- a/spring-boot-samples/spring-boot-sample-oauth2-client/src/test/java/sample/oauth2/client/SampleOAuth2ClientApplicationTests.java
+++ b/spring-boot-samples/spring-boot-sample-oauth2-client/src/test/java/sample/oauth2/client/SampleOAuth2ClientApplicationTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2017 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-boot-samples/spring-boot-sample-parent-context/src/main/java/sample/parent/SampleParentContextApplication.java b/spring-boot-samples/spring-boot-sample-parent-context/src/main/java/sample/parent/SampleParentContextApplication.java
index 54a5de2401a..2b0f879a490 100644
--- a/spring-boot-samples/spring-boot-sample-parent-context/src/main/java/sample/parent/SampleParentContextApplication.java
+++ b/spring-boot-samples/spring-boot-sample-parent-context/src/main/java/sample/parent/SampleParentContextApplication.java
@@ -36,6 +36,11 @@ import org.springframework.integration.file.FileWritingMessageHandler;
@EnableConfigurationProperties(ServiceProperties.class)
public class SampleParentContextApplication {
+ public static void main(String[] args) throws Exception {
+ new SpringApplicationBuilder(Parent.class)
+ .child(SampleParentContextApplication.class).run(args);
+ }
+
@EnableAutoConfiguration
protected static class Parent {
@@ -83,9 +88,4 @@ public class SampleParentContextApplication {
}
- public static void main(String[] args) {
- new SpringApplicationBuilder(Parent.class)
- .child(SampleParentContextApplication.class).run(args);
- }
-
}
diff --git a/spring-boot-samples/spring-boot-sample-parent-context/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-parent-context/src/main/resources/application.properties
index b04af6c76a1..503d925fb60 100644
--- a/spring-boot-samples/spring-boot-sample-parent-context/src/main/resources/application.properties
+++ b/spring-boot-samples/spring-boot-sample-parent-context/src/main/resources/application.properties
@@ -1 +1 @@
-service.greeting=Hello
\ No newline at end of file
+service.greeting=Hello
diff --git a/spring-boot-samples/spring-boot-sample-parent-context/src/test/java/sample/parent/consumer/SampleIntegrationParentApplicationTests.java b/spring-boot-samples/spring-boot-sample-parent-context/src/test/java/sample/parent/consumer/SampleIntegrationParentApplicationTests.java
index 3e9865d578c..ba852c2835e 100644
--- a/spring-boot-samples/spring-boot-sample-parent-context/src/test/java/sample/parent/consumer/SampleIntegrationParentApplicationTests.java
+++ b/spring-boot-samples/spring-boot-sample-parent-context/src/test/java/sample/parent/consumer/SampleIntegrationParentApplicationTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2015 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -99,4 +99,5 @@ public class SampleIntegrationParentApplicationTests {
}
return builder.toString();
}
+
}
diff --git a/spring-boot-samples/spring-boot-sample-profile/src/main/java/sample/profile/service/MessageService.java b/spring-boot-samples/spring-boot-sample-profile/src/main/java/sample/profile/service/MessageService.java
index d322b7a50e1..0199208bfcc 100644
--- a/spring-boot-samples/spring-boot-sample-profile/src/main/java/sample/profile/service/MessageService.java
+++ b/spring-boot-samples/spring-boot-sample-profile/src/main/java/sample/profile/service/MessageService.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2013 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,9 +16,6 @@
package sample.profile.service;
-/**
- * @author Dave Syer
- */
public interface MessageService {
String getMessage();
diff --git a/spring-boot-samples/spring-boot-sample-property-validation/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-property-validation/src/main/resources/application.properties
index b28381563f2..db673a37963 100644
--- a/spring-boot-samples/spring-boot-sample-property-validation/src/main/resources/application.properties
+++ b/spring-boot-samples/spring-boot-sample-property-validation/src/main/resources/application.properties
@@ -1,2 +1,2 @@
sample.host=192.168.0.1
-sample.port=7070
\ No newline at end of file
+sample.port=7070
diff --git a/spring-boot-samples/spring-boot-sample-quartz/src/main/java/sample/quartz/SampleJob.java b/spring-boot-samples/spring-boot-sample-quartz/src/main/java/sample/quartz/SampleJob.java
index e00d71d8fe7..4e5a961a77d 100644
--- a/spring-boot-samples/spring-boot-sample-quartz/src/main/java/sample/quartz/SampleJob.java
+++ b/spring-boot-samples/spring-boot-sample-quartz/src/main/java/sample/quartz/SampleJob.java
@@ -1,5 +1,9 @@
/*
+<<<<<<< HEAD:spring-boot-samples/spring-boot-sample-quartz/src/main/java/sample/quartz/SampleJob.java
* Copyright 2012-2017 the original author or authors.
+=======
+ * Copyright 2012-2018 the original author or authors.
+>>>>>>> local15x/1.5.x:spring-boot-samples/spring-boot-sample-hibernate4/src/main/java/sample/hibernate4/service/CitySearchCriteria.java
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-boot-samples/spring-boot-sample-quartz/src/main/java/sample/quartz/SampleQuartzApplication.java b/spring-boot-samples/spring-boot-sample-quartz/src/main/java/sample/quartz/SampleQuartzApplication.java
index 54f82f17340..b679e62335e 100644
--- a/spring-boot-samples/spring-boot-sample-quartz/src/main/java/sample/quartz/SampleQuartzApplication.java
+++ b/spring-boot-samples/spring-boot-sample-quartz/src/main/java/sample/quartz/SampleQuartzApplication.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2017 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-boot-samples/spring-boot-sample-secure/src/main/java/sample/secure/SampleService.java b/spring-boot-samples/spring-boot-sample-secure/src/main/java/sample/secure/SampleService.java
index ff022dc9de4..d8fb861e98b 100644
--- a/spring-boot-samples/spring-boot-sample-secure/src/main/java/sample/secure/SampleService.java
+++ b/spring-boot-samples/spring-boot-sample-secure/src/main/java/sample/secure/SampleService.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2014 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,10 +20,6 @@ import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Service;
-/**
- * @author Dave Syer
- *
- */
@Service
public class SampleService {
diff --git a/spring-boot-samples/spring-boot-sample-secure/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-secure/src/main/resources/application.properties
index 95ac83170e4..b90b32b4e79 100644
--- a/spring-boot-samples/spring-boot-sample-secure/src/main/resources/application.properties
+++ b/spring-boot-samples/spring-boot-sample-secure/src/main/resources/application.properties
@@ -1,4 +1,4 @@
# debug: true
spring.security.user.name=user
spring.security.user.password=password
-spring.security.user.roles=USER
\ No newline at end of file
+spring.security.user.roles=USER
diff --git a/spring-boot-samples/spring-boot-sample-secure/src/test/java/sample/secure/SampleSecureApplicationTests.java b/spring-boot-samples/spring-boot-sample-secure/src/test/java/sample/secure/SampleSecureApplicationTests.java
index 17ad27d59bd..616f1fcbc1e 100644
--- a/spring-boot-samples/spring-boot-sample-secure/src/test/java/sample/secure/SampleSecureApplicationTests.java
+++ b/spring-boot-samples/spring-boot-sample-secure/src/test/java/sample/secure/SampleSecureApplicationTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2017 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-boot-samples/spring-boot-sample-secure/src/test/resources/test.properties b/spring-boot-samples/spring-boot-sample-secure/src/test/resources/test.properties
deleted file mode 100644
index e69de29bb2d..00000000000
diff --git a/spring-boot-samples/spring-boot-sample-servlet/src/test/java/sample/servlet/SampleServletApplicationTests.java b/spring-boot-samples/spring-boot-sample-servlet/src/test/java/sample/servlet/SampleServletApplicationTests.java
index c87af750ea3..97fa05a4be4 100644
--- a/spring-boot-samples/spring-boot-sample-servlet/src/test/java/sample/servlet/SampleServletApplicationTests.java
+++ b/spring-boot-samples/spring-boot-sample-servlet/src/test/java/sample/servlet/SampleServletApplicationTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2017 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -67,4 +67,5 @@ public class SampleServletApplicationTests {
private String getPassword() {
return "password";
}
+
}
diff --git a/spring-boot-samples/spring-boot-sample-test/src/main/java/sample/test/service/VehicleIdentificationNumberNotFoundException.java b/spring-boot-samples/spring-boot-sample-test/src/main/java/sample/test/service/VehicleIdentificationNumberNotFoundException.java
index cfa7b590470..8e4d7306ea9 100644
--- a/spring-boot-samples/spring-boot-sample-test/src/main/java/sample/test/service/VehicleIdentificationNumberNotFoundException.java
+++ b/spring-boot-samples/spring-boot-sample-test/src/main/java/sample/test/service/VehicleIdentificationNumberNotFoundException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2016 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,7 +25,7 @@ import sample.test.domain.VehicleIdentificationNumber;
*/
public class VehicleIdentificationNumberNotFoundException extends RuntimeException {
- private VehicleIdentificationNumber vehicleIdentificationNumber;
+ private final VehicleIdentificationNumber vehicleIdentificationNumber;
public VehicleIdentificationNumberNotFoundException(VehicleIdentificationNumber vin) {
this(vin, null);
@@ -40,4 +40,5 @@ public class VehicleIdentificationNumberNotFoundException extends RuntimeExcepti
public VehicleIdentificationNumber getVehicleIdentificationNumber() {
return this.vehicleIdentificationNumber;
}
+
}
diff --git a/spring-boot-samples/spring-boot-sample-test/src/main/java/sample/test/web/UserNameNotFoundException.java b/spring-boot-samples/spring-boot-sample-test/src/main/java/sample/test/web/UserNameNotFoundException.java
index 4c4a1e680bb..a30292aceda 100644
--- a/spring-boot-samples/spring-boot-sample-test/src/main/java/sample/test/web/UserNameNotFoundException.java
+++ b/spring-boot-samples/spring-boot-sample-test/src/main/java/sample/test/web/UserNameNotFoundException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2016 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@ import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(HttpStatus.NOT_FOUND)
public class UserNameNotFoundException extends RuntimeException {
- private String username;
+ private final String username;
public UserNameNotFoundException(String username) {
this.username = username;
diff --git a/spring-boot-samples/spring-boot-sample-tomcat-jsp/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-tomcat-jsp/src/main/resources/application.properties
index 2af7f6e200d..b4c95bf8e7f 100644
--- a/spring-boot-samples/spring-boot-sample-tomcat-jsp/src/main/resources/application.properties
+++ b/spring-boot-samples/spring-boot-sample-tomcat-jsp/src/main/resources/application.properties
@@ -1,3 +1,3 @@
spring.mvc.view.prefix: /WEB-INF/jsp/
spring.mvc.view.suffix: .jsp
-application.message: Hello Phil
\ No newline at end of file
+application.message: Hello Phil
diff --git a/spring-boot-samples/spring-boot-sample-tomcat-multi-connectors/src/main/java/sample/tomcat/multiconnector/SampleTomcatTwoConnectorsApplication.java b/spring-boot-samples/spring-boot-sample-tomcat-multi-connectors/src/main/java/sample/tomcat/multiconnector/SampleTomcatTwoConnectorsApplication.java
index 75d96354aa5..c55ecd86afb 100644
--- a/spring-boot-samples/spring-boot-sample-tomcat-multi-connectors/src/main/java/sample/tomcat/multiconnector/SampleTomcatTwoConnectorsApplication.java
+++ b/spring-boot-samples/spring-boot-sample-tomcat-multi-connectors/src/main/java/sample/tomcat/multiconnector/SampleTomcatTwoConnectorsApplication.java
@@ -25,7 +25,7 @@ import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;
/**
- * Sample Application to show Tomcat running two connectors
+ * Sample Application to show Tomcat running two connectors.
*
* @author Brock Mills
* @author Andy Wilkinson
diff --git a/spring-boot-samples/spring-boot-sample-tomcat-multi-connectors/src/test/java/sample/tomcat/multiconnector/SampleTomcatTwoConnectorsApplicationTests.java b/spring-boot-samples/spring-boot-sample-tomcat-multi-connectors/src/test/java/sample/tomcat/multiconnector/SampleTomcatTwoConnectorsApplicationTests.java
index c206dc79cdc..aa94a487569 100644
--- a/spring-boot-samples/spring-boot-sample-tomcat-multi-connectors/src/test/java/sample/tomcat/multiconnector/SampleTomcatTwoConnectorsApplicationTests.java
+++ b/spring-boot-samples/spring-boot-sample-tomcat-multi-connectors/src/test/java/sample/tomcat/multiconnector/SampleTomcatTwoConnectorsApplicationTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2017 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-boot-samples/spring-boot-sample-tomcat/src/test/java/sample/tomcat/NonAutoConfigurationSampleTomcatApplicationTests.java b/spring-boot-samples/spring-boot-sample-tomcat/src/test/java/sample/tomcat/NonAutoConfigurationSampleTomcatApplicationTests.java
index 4447bf3ffc6..939a4cfcec4 100644
--- a/spring-boot-samples/spring-boot-sample-tomcat/src/test/java/sample/tomcat/NonAutoConfigurationSampleTomcatApplicationTests.java
+++ b/spring-boot-samples/spring-boot-sample-tomcat/src/test/java/sample/tomcat/NonAutoConfigurationSampleTomcatApplicationTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2017 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,6 +52,13 @@ public class NonAutoConfigurationSampleTomcatApplicationTests {
@Autowired
private TestRestTemplate restTemplate;
+ @Test
+ public void testHome() throws Exception {
+ ResponseEntity entity = this.restTemplate.getForEntity("/", String.class);
+ assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
+ assertThat(entity.getBody()).isEqualTo("Hello World");
+ }
+
@Configuration
@Import({ ServletWebServerFactoryAutoConfiguration.class,
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
@@ -67,11 +74,4 @@ public class NonAutoConfigurationSampleTomcatApplicationTests {
}
- @Test
- public void testHome() {
- ResponseEntity entity = this.restTemplate.getForEntity("/", String.class);
- assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
- assertThat(entity.getBody()).isEqualTo("Hello World");
- }
-
}
diff --git a/spring-boot-samples/spring-boot-sample-traditional/src/main/java/sample/traditional/config/WebConfig.java b/spring-boot-samples/spring-boot-sample-traditional/src/main/java/sample/traditional/config/WebConfig.java
index 962d8946e21..faa679fa0e1 100644
--- a/spring-boot-samples/spring-boot-sample-traditional/src/main/java/sample/traditional/config/WebConfig.java
+++ b/spring-boot-samples/spring-boot-sample-traditional/src/main/java/sample/traditional/config/WebConfig.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2017 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -55,4 +55,5 @@ public class WebConfig implements WebMvcConfigurer {
DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
+
}
diff --git a/spring-boot-samples/spring-boot-sample-undertow-ssl/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-undertow-ssl/src/main/resources/application.properties
index 953abe0d6c9..37199bfd256 100644
--- a/spring-boot-samples/spring-boot-sample-undertow-ssl/src/main/resources/application.properties
+++ b/spring-boot-samples/spring-boot-sample-undertow-ssl/src/main/resources/application.properties
@@ -1,4 +1,4 @@
server.port = 8443
server.ssl.key-store = classpath:sample.jks
server.ssl.key-store-password = secret
-server.ssl.key-password = password
\ No newline at end of file
+server.ssl.key-password = password
diff --git a/spring-boot-samples/spring-boot-sample-undertow/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-undertow/src/main/resources/application.properties
index bb809f2a9c7..7dfb55689a3 100644
--- a/spring-boot-samples/spring-boot-sample-undertow/src/main/resources/application.properties
+++ b/spring-boot-samples/spring-boot-sample-undertow/src/main/resources/application.properties
@@ -2,4 +2,4 @@ server.undertow.accesslog.enabled=true
server.undertow.accesslog.dir=target/logs
server.undertow.accesslog.pattern=combined
server.compression.enabled=true
-server.compression.min-response-size=1
\ No newline at end of file
+server.compression.min-response-size=1
diff --git a/spring-boot-samples/spring-boot-sample-war/src/main/java/sample/war/SampleWarApplication.java b/spring-boot-samples/spring-boot-sample-war/src/main/java/sample/war/SampleWarApplication.java
index 09be74e4b38..cd6614ed920 100644
--- a/spring-boot-samples/spring-boot-sample-war/src/main/java/sample/war/SampleWarApplication.java
+++ b/spring-boot-samples/spring-boot-sample-war/src/main/java/sample/war/SampleWarApplication.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2017 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,11 +21,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.PropertySource;
-/**
- * Sample WAR application
- */
@SpringBootApplication
-@PropertySource(value = { "WEB-INF/custom.properties" })
+@PropertySource("WEB-INF/custom.properties")
public class SampleWarApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
diff --git a/spring-boot-samples/spring-boot-sample-web-freemarker/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-web-freemarker/src/main/resources/application.properties
index edea37a1cf6..e504f79eb9c 100644
--- a/spring-boot-samples/spring-boot-sample-web-freemarker/src/main/resources/application.properties
+++ b/spring-boot-samples/spring-boot-sample-web-freemarker/src/main/resources/application.properties
@@ -1 +1 @@
-application.message: Hello, Andy
\ No newline at end of file
+application.message: Hello, Andy
diff --git a/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/java/sample/groovytemplates/Message.java b/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/java/sample/groovytemplates/Message.java
index a257587955c..57d033398ed 100644
--- a/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/java/sample/groovytemplates/Message.java
+++ b/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/java/sample/groovytemplates/Message.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2017 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/resources/application.properties
index 14bc33fa926..097a5a4fbe4 100644
--- a/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/resources/application.properties
+++ b/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/resources/application.properties
@@ -1,3 +1,3 @@
# Allow templates to be reloaded at dev time
spring.groovy.template.cache: false
-logging.level.org.springframework.web: INFO
\ No newline at end of file
+logging.level.org.springframework.web: INFO
diff --git a/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/test/java/sample/groovytemplates/MessageControllerWebTests.java b/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/test/java/sample/groovytemplates/MessageControllerWebTests.java
index 5ac926d2f3b..1943e96b3fc 100755
--- a/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/test/java/sample/groovytemplates/MessageControllerWebTests.java
+++ b/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/test/java/sample/groovytemplates/MessageControllerWebTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2017 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -82,14 +82,10 @@ public class MessageControllerWebTests {
private final String regex;
- public RegexMatcher(String regex) {
+ RegexMatcher(String regex) {
this.regex = regex;
}
- public static org.hamcrest.Matcher matches(String regex) {
- return new RegexMatcher(regex);
- }
-
@Override
public boolean matchesSafely(String item) {
return Pattern.compile(this.regex).matcher(item).find();
@@ -106,6 +102,10 @@ public class MessageControllerWebTests {
.appendText(this.regex);
}
+ public static org.hamcrest.Matcher matches(String regex) {
+ return new RegexMatcher(regex);
+ }
+
}
}
diff --git a/spring-boot-samples/spring-boot-sample-web-jsp/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-web-jsp/src/main/resources/application.properties
index 2af7f6e200d..b4c95bf8e7f 100644
--- a/spring-boot-samples/spring-boot-sample-web-jsp/src/main/resources/application.properties
+++ b/spring-boot-samples/spring-boot-sample-web-jsp/src/main/resources/application.properties
@@ -1,3 +1,3 @@
spring.mvc.view.prefix: /WEB-INF/jsp/
spring.mvc.view.suffix: .jsp
-application.message: Hello Phil
\ No newline at end of file
+application.message: Hello Phil
diff --git a/spring-boot-samples/spring-boot-sample-web-method-security/src/main/java/sample/security/method/SampleMethodSecurityApplication.java b/spring-boot-samples/spring-boot-sample-web-method-security/src/main/java/sample/security/method/SampleMethodSecurityApplication.java
index 355b0b0e11d..e3cac811dad 100644
--- a/spring-boot-samples/spring-boot-sample-web-method-security/src/main/java/sample/security/method/SampleMethodSecurityApplication.java
+++ b/spring-boot-samples/spring-boot-sample-web-method-security/src/main/java/sample/security/method/SampleMethodSecurityApplication.java
@@ -42,20 +42,6 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@EnableGlobalMethodSecurity(securedEnabled = true)
public class SampleMethodSecurityApplication implements WebMvcConfigurer {
- @Controller
- protected static class HomeController {
-
- @GetMapping("/")
- @Secured("ROLE_ADMIN")
- public String home(Map model) {
- model.put("message", "Hello World");
- model.put("title", "Hello Home");
- model.put("date", new Date());
- return "home";
- }
-
- }
-
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/login").setViewName("login");
@@ -118,4 +104,18 @@ public class SampleMethodSecurityApplication implements WebMvcConfigurer {
}
+ @Controller
+ protected static class HomeController {
+
+ @GetMapping("/")
+ @Secured("ROLE_ADMIN")
+ public String home(Map model) {
+ model.put("message", "Hello World");
+ model.put("title", "Hello Home");
+ model.put("date", new Date());
+ return "home";
+ }
+
+ }
+
}
diff --git a/spring-boot-samples/spring-boot-sample-web-mustache/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-web-mustache/src/main/resources/application.properties
index edea37a1cf6..e504f79eb9c 100644
--- a/spring-boot-samples/spring-boot-sample-web-mustache/src/main/resources/application.properties
+++ b/spring-boot-samples/spring-boot-sample-web-mustache/src/main/resources/application.properties
@@ -1 +1 @@
-application.message: Hello, Andy
\ No newline at end of file
+application.message: Hello, Andy
diff --git a/spring-boot-samples/spring-boot-sample-web-secure-custom/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-web-secure-custom/src/main/resources/application.properties
index 3509ac7bd40..f70a1c0333a 100644
--- a/spring-boot-samples/spring-boot-sample-web-secure-custom/src/main/resources/application.properties
+++ b/spring-boot-samples/spring-boot-sample-web-secure-custom/src/main/resources/application.properties
@@ -1,5 +1,4 @@
spring.thymeleaf.cache: false
logging.level.org.springframework.security: INFO
-
spring.security.user.name=user
-spring.security.user.password=password
\ No newline at end of file
+spring.security.user.password=password
diff --git a/spring-boot-samples/spring-boot-sample-web-secure-jdbc/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-web-secure-jdbc/src/main/resources/application.properties
index ae895e68637..707dec09284 100644
--- a/spring-boot-samples/spring-boot-sample-web-secure-jdbc/src/main/resources/application.properties
+++ b/spring-boot-samples/spring-boot-sample-web-secure-jdbc/src/main/resources/application.properties
@@ -1,3 +1,3 @@
debug: true
spring.thymeleaf.cache: false
-logging.level.org.springframework.security: INFO
\ No newline at end of file
+logging.level.org.springframework.security: INFO
diff --git a/spring-boot-samples/spring-boot-sample-web-secure/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-web-secure/src/main/resources/application.properties
index aba18894067..fbb48e382f7 100644
--- a/spring-boot-samples/spring-boot-sample-web-secure/src/main/resources/application.properties
+++ b/spring-boot-samples/spring-boot-sample-web-secure/src/main/resources/application.properties
@@ -2,6 +2,5 @@ spring.thymeleaf.cache: false
# demo only:
logging.level.org.springframework.security: INFO
logging.level.org.springframework.boot.actuate.audit.listener.AuditListener: DEBUG
-
spring.security.user.name=user
-spring.security.user.password=password
\ No newline at end of file
+spring.security.user.password=password
diff --git a/spring-boot-samples/spring-boot-sample-web-ui/src/main/java/sample/web/ui/InMemoryMessageRepository.java b/spring-boot-samples/spring-boot-sample-web-ui/src/main/java/sample/web/ui/InMemoryMessageRepository.java
index 4d3c3727527..c68de3d8fd3 100755
--- a/spring-boot-samples/spring-boot-sample-web-ui/src/main/java/sample/web/ui/InMemoryMessageRepository.java
+++ b/spring-boot-samples/spring-boot-sample-web-ui/src/main/java/sample/web/ui/InMemoryMessageRepository.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2017 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,9 +20,6 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicLong;
-/**
- * @author Dave Syer
- */
public class InMemoryMessageRepository implements MessageRepository {
private static AtomicLong counter = new AtomicLong();
diff --git a/spring-boot-samples/spring-boot-sample-web-ui/src/main/java/sample/web/ui/Message.java b/spring-boot-samples/spring-boot-sample-web-ui/src/main/java/sample/web/ui/Message.java
index fbaa4d194ad..02c83d18e0f 100644
--- a/spring-boot-samples/spring-boot-sample-web-ui/src/main/java/sample/web/ui/Message.java
+++ b/spring-boot-samples/spring-boot-sample-web-ui/src/main/java/sample/web/ui/Message.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2017 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,9 +20,6 @@ import java.util.Calendar;
import javax.validation.constraints.NotEmpty;
-/**
- * @author Rob Winch
- */
public class Message {
private Long id;
diff --git a/spring-boot-samples/spring-boot-sample-web-ui/src/main/java/sample/web/ui/MessageRepository.java b/spring-boot-samples/spring-boot-sample-web-ui/src/main/java/sample/web/ui/MessageRepository.java
index 52c336c43a1..abfa61ef622 100755
--- a/spring-boot-samples/spring-boot-sample-web-ui/src/main/java/sample/web/ui/MessageRepository.java
+++ b/spring-boot-samples/spring-boot-sample-web-ui/src/main/java/sample/web/ui/MessageRepository.java
@@ -1,21 +1,21 @@
/*
- * Copyright 2012-2015 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package sample.web.ui;
-/**
- * @author Rob Winch
- */
public interface MessageRepository {
Iterable findAll();
diff --git a/spring-boot-samples/spring-boot-sample-web-ui/src/main/java/sample/web/ui/mvc/MessageController.java b/spring-boot-samples/spring-boot-sample-web-ui/src/main/java/sample/web/ui/mvc/MessageController.java
index 4f144fd2888..f66f54df484 100755
--- a/spring-boot-samples/spring-boot-sample-web-ui/src/main/java/sample/web/ui/mvc/MessageController.java
+++ b/spring-boot-samples/spring-boot-sample-web-ui/src/main/java/sample/web/ui/mvc/MessageController.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2016 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,10 +31,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
-/**
- * @author Rob Winch
- * @author Doo-Hwan Kwak
- */
@Controller
@RequestMapping("/")
public class MessageController {
@@ -77,14 +73,14 @@ public class MessageController {
throw new RuntimeException("Expected exception in controller");
}
- @GetMapping(value = "delete/{id}")
+ @GetMapping("delete/{id}")
public ModelAndView delete(@PathVariable("id") Long id) {
this.messageRepository.deleteMessage(id);
Iterable messages = this.messageRepository.findAll();
return new ModelAndView("messages/list", "messages", messages);
}
- @GetMapping(value = "modify/{id}")
+ @GetMapping("modify/{id}")
public ModelAndView modifyForm(@PathVariable("id") Message message) {
return new ModelAndView("messages/form", "message", message);
}
diff --git a/spring-boot-samples/spring-boot-sample-web-ui/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-web-ui/src/main/resources/application.properties
index 6665cd62d35..c20caf35b13 100644
--- a/spring-boot-samples/spring-boot-sample-web-ui/src/main/resources/application.properties
+++ b/spring-boot-samples/spring-boot-sample-web-ui/src/main/resources/application.properties
@@ -1,4 +1,4 @@
# Allow Thymeleaf templates to be reloaded at dev time
spring.thymeleaf.cache: false
server.tomcat.access_log_enabled: true
-server.tomcat.basedir: target/tomcat
\ No newline at end of file
+server.tomcat.basedir: target/tomcat
diff --git a/spring-boot-samples/spring-boot-sample-web-ui/src/test/java/sample/web/ui/MessageControllerWebTests.java b/spring-boot-samples/spring-boot-sample-web-ui/src/test/java/sample/web/ui/MessageControllerWebTests.java
index 007e52173ee..76d21990515 100644
--- a/spring-boot-samples/spring-boot-sample-web-ui/src/test/java/sample/web/ui/MessageControllerWebTests.java
+++ b/spring-boot-samples/spring-boot-sample-web-ui/src/test/java/sample/web/ui/MessageControllerWebTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2016 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -81,16 +81,13 @@ public class MessageControllerWebTests {
}
private static class RegexMatcher extends TypeSafeMatcher {
+
private final String regex;
- public RegexMatcher(String regex) {
+ RegexMatcher(String regex) {
this.regex = regex;
}
- public static org.hamcrest.Matcher matches(String regex) {
- return new RegexMatcher(regex);
- }
-
@Override
public boolean matchesSafely(String item) {
return Pattern.compile(this.regex).matcher(item).find();
@@ -106,5 +103,11 @@ public class MessageControllerWebTests {
description.appendText("a string that matches regex: ")
.appendText(this.regex);
}
+
+ public static org.hamcrest.Matcher matches(String regex) {
+ return new RegexMatcher(regex);
+ }
+
}
+
}
diff --git a/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/echo/DefaultEchoService.java b/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/echo/DefaultEchoService.java
index 572fb316ea0..dcb00af08e3 100644
--- a/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/echo/DefaultEchoService.java
+++ b/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/echo/DefaultEchoService.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2015 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@ public class DefaultEchoService implements EchoService {
private final String echoFormat;
public DefaultEchoService(String echoFormat) {
- this.echoFormat = (echoFormat != null) ? echoFormat : "%s";
+ this.echoFormat = (echoFormat != null ? echoFormat : "%s");
}
@Override
diff --git a/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/reverse/ReverseWebSocketEndpoint.java b/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/reverse/ReverseWebSocketEndpoint.java
index 049835bd59a..76837c7e093 100644
--- a/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/reverse/ReverseWebSocketEndpoint.java
+++ b/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/reverse/ReverseWebSocketEndpoint.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2015 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,4 +30,5 @@ public class ReverseWebSocketEndpoint {
session.getBasicRemote()
.sendText("Reversed: " + new StringBuilder(message).reverse());
}
+
}
diff --git a/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/snake/Direction.java b/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/snake/Direction.java
index 96871610fff..64fafba56f1 100644
--- a/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/snake/Direction.java
+++ b/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/snake/Direction.java
@@ -1,10 +1,9 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Copyright 2012-2018 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@@ -18,5 +17,7 @@
package samples.websocket.jetty.snake;
public enum Direction {
+
NONE, NORTH, SOUTH, EAST, WEST
+
}
diff --git a/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/snake/Location.java b/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/snake/Location.java
index f2abe5faeb3..4f18c3ee0c2 100644
--- a/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/snake/Location.java
+++ b/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/snake/Location.java
@@ -1,10 +1,9 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Copyright 2012-2018 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@@ -19,11 +18,15 @@ package samples.websocket.jetty.snake;
public class Location {
+ /**
+ * The X location.
+ */
public int x;
+
+ /**
+ * The Y location.
+ */
public int y;
- public static final int GRID_SIZE = 10;
- public static final int PLAYFIELD_HEIGHT = 480;
- public static final int PLAYFIELD_WIDTH = 640;
public Location(int x, int y) {
this.x = x;
@@ -33,13 +36,13 @@ public class Location {
public Location getAdjacentLocation(Direction direction) {
switch (direction) {
case NORTH:
- return new Location(this.x, this.y - Location.GRID_SIZE);
+ return new Location(this.x, this.y - SnakeUtils.GRID_SIZE);
case SOUTH:
- return new Location(this.x, this.y + Location.GRID_SIZE);
+ return new Location(this.x, this.y + SnakeUtils.GRID_SIZE);
case EAST:
- return new Location(this.x + Location.GRID_SIZE, this.y);
+ return new Location(this.x + SnakeUtils.GRID_SIZE, this.y);
case WEST:
- return new Location(this.x - Location.GRID_SIZE, this.y);
+ return new Location(this.x - SnakeUtils.GRID_SIZE, this.y);
case NONE:
// fall through
default:
@@ -55,16 +58,13 @@ public class Location {
if (o == null || getClass() != o.getClass()) {
return false;
}
-
Location location = (Location) o;
-
if (this.x != location.x) {
return false;
}
if (this.y != location.y) {
return false;
}
-
return true;
}
@@ -74,4 +74,5 @@ public class Location {
result = 31 * result + this.y;
return result;
}
+
}
diff --git a/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/snake/Snake.java b/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/snake/Snake.java
index 39ffc8de805..8c42e1943c1 100644
--- a/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/snake/Snake.java
+++ b/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/snake/Snake.java
@@ -1,10 +1,9 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Copyright 2012-2018 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@@ -157,4 +156,5 @@ public class Snake {
public String getHexColor() {
return this.hexColor;
}
+
}
diff --git a/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/snake/SnakeTimer.java b/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/snake/SnakeTimer.java
index af0d7c65260..0295c9b6265 100644
--- a/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/snake/SnakeTimer.java
+++ b/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/snake/SnakeTimer.java
@@ -1,10 +1,9 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Copyright 2012-2018 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@@ -31,7 +30,7 @@ import org.slf4j.LoggerFactory;
/**
* Sets up the timer for the multi-player snake game WebSocket example.
*/
-public class SnakeTimer {
+public final class SnakeTimer {
private static final long TICK_DELAY = 100;
@@ -43,6 +42,9 @@ public class SnakeTimer {
private static Timer gameTimer = null;
+ private SnakeTimer() {
+ }
+
public static void addSnake(Snake snake) {
synchronized (MONITOR) {
if (snakes.isEmpty()) {
@@ -112,4 +114,5 @@ public class SnakeTimer {
gameTimer.cancel();
}
}
+
}
diff --git a/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/snake/SnakeUtils.java b/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/snake/SnakeUtils.java
index 01e4d7e80be..c522d80a891 100644
--- a/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/snake/SnakeUtils.java
+++ b/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/snake/SnakeUtils.java
@@ -1,10 +1,9 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Copyright 2012-2018 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@@ -20,14 +19,28 @@ package samples.websocket.jetty.snake;
import java.awt.Color;
import java.util.Random;
-public class SnakeUtils {
+public final class SnakeUtils {
+ /**
+ * The width of the playfield.
+ */
public static final int PLAYFIELD_WIDTH = 640;
+
+ /**
+ * The height of the playfield.
+ */
public static final int PLAYFIELD_HEIGHT = 480;
+
+ /**
+ * The grid size.
+ */
public static final int GRID_SIZE = 10;
private static final Random random = new Random();
+ private SnakeUtils() {
+ }
+
public static String getRandomHexColor() {
float hue = random.nextFloat();
// sat between 0.1 and 0.3
diff --git a/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/snake/SnakeWebSocketHandler.java b/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/snake/SnakeWebSocketHandler.java
index da2d1351820..50d0875c0a5 100644
--- a/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/snake/SnakeWebSocketHandler.java
+++ b/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/snake/SnakeWebSocketHandler.java
@@ -1,10 +1,9 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Copyright 2012-2018 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@@ -29,14 +28,12 @@ import org.springframework.web.socket.handler.TextWebSocketHandler;
public class SnakeWebSocketHandler extends TextWebSocketHandler {
- public static final int PLAYFIELD_WIDTH = 640;
- public static final int PLAYFIELD_HEIGHT = 480;
- public static final int GRID_SIZE = 10;
-
private static final AtomicInteger snakeIds = new AtomicInteger(0);
+
private static final Random random = new Random();
private final int id;
+
private Snake snake;
public static String getRandomHexColor() {
@@ -50,15 +47,15 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler {
}
public static Location getRandomLocation() {
- int x = roundByGridSize(random.nextInt(PLAYFIELD_WIDTH));
- int y = roundByGridSize(random.nextInt(PLAYFIELD_HEIGHT));
+ int x = roundByGridSize(random.nextInt(SnakeUtils.PLAYFIELD_WIDTH));
+ int y = roundByGridSize(random.nextInt(SnakeUtils.PLAYFIELD_HEIGHT));
return new Location(x, y);
}
private static int roundByGridSize(int value) {
- value = value + (GRID_SIZE / 2);
- value = value / GRID_SIZE;
- value = value * GRID_SIZE;
+ value = value + (SnakeUtils.GRID_SIZE / 2);
+ value = value / SnakeUtils.GRID_SIZE;
+ value = value * SnakeUtils.GRID_SIZE;
return value;
}
@@ -109,4 +106,5 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler {
SnakeTimer.broadcast(
String.format("{'type': 'leave', 'id': %d}", Integer.valueOf(this.id)));
}
+
}
diff --git a/spring-boot-samples/spring-boot-sample-websocket-jetty/src/test/java/samples/websocket/jetty/SampleWebSocketsApplicationTests.java b/spring-boot-samples/spring-boot-sample-websocket-jetty/src/test/java/samples/websocket/jetty/SampleWebSocketsApplicationTests.java
index cf9445d47b4..2be99ce78da 100644
--- a/spring-boot-samples/spring-boot-sample-websocket-jetty/src/test/java/samples/websocket/jetty/SampleWebSocketsApplicationTests.java
+++ b/spring-boot-samples/spring-boot-sample-websocket-jetty/src/test/java/samples/websocket/jetty/SampleWebSocketsApplicationTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2017 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -130,6 +130,7 @@ public class SampleWebSocketsApplicationTests {
public GreetingService greetingService() {
return new SimpleGreetingService();
}
+
}
}
diff --git a/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/echo/DefaultEchoService.java b/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/echo/DefaultEchoService.java
index 0bd2fd222b1..d6b82ce10ad 100644
--- a/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/echo/DefaultEchoService.java
+++ b/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/echo/DefaultEchoService.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2015 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@ public class DefaultEchoService implements EchoService {
private final String echoFormat;
public DefaultEchoService(String echoFormat) {
- this.echoFormat = (echoFormat != null) ? echoFormat : "%s";
+ this.echoFormat = (echoFormat != null ? echoFormat : "%s");
}
@Override
diff --git a/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/reverse/ReverseWebSocketEndpoint.java b/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/reverse/ReverseWebSocketEndpoint.java
index f0fb893daee..9911653e30c 100644
--- a/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/reverse/ReverseWebSocketEndpoint.java
+++ b/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/reverse/ReverseWebSocketEndpoint.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2015 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,4 +30,5 @@ public class ReverseWebSocketEndpoint {
session.getBasicRemote()
.sendText("Reversed: " + new StringBuilder(message).reverse());
}
+
}
diff --git a/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/snake/Direction.java b/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/snake/Direction.java
index bd2c2e71b90..1dad076b012 100644
--- a/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/snake/Direction.java
+++ b/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/snake/Direction.java
@@ -1,10 +1,9 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Copyright 2012-2018 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@@ -18,5 +17,7 @@
package samples.websocket.tomcat.snake;
public enum Direction {
+
NONE, NORTH, SOUTH, EAST, WEST
+
}
diff --git a/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/snake/Location.java b/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/snake/Location.java
index 2d86ff41ba5..b0e79a36c6c 100644
--- a/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/snake/Location.java
+++ b/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/snake/Location.java
@@ -1,10 +1,9 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Copyright 2012-2018 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@@ -19,11 +18,15 @@ package samples.websocket.tomcat.snake;
public class Location {
+ /**
+ * The X location.
+ */
public int x;
+
+ /**
+ * The Y location.
+ */
public int y;
- public static final int GRID_SIZE = 10;
- public static final int PLAYFIELD_HEIGHT = 480;
- public static final int PLAYFIELD_WIDTH = 640;
public Location(int x, int y) {
this.x = x;
@@ -33,13 +36,13 @@ public class Location {
public Location getAdjacentLocation(Direction direction) {
switch (direction) {
case NORTH:
- return new Location(this.x, this.y - Location.GRID_SIZE);
+ return new Location(this.x, this.y - SnakeUtils.GRID_SIZE);
case SOUTH:
- return new Location(this.x, this.y + Location.GRID_SIZE);
+ return new Location(this.x, this.y + SnakeUtils.GRID_SIZE);
case EAST:
- return new Location(this.x + Location.GRID_SIZE, this.y);
+ return new Location(this.x + SnakeUtils.GRID_SIZE, this.y);
case WEST:
- return new Location(this.x - Location.GRID_SIZE, this.y);
+ return new Location(this.x - SnakeUtils.GRID_SIZE, this.y);
case NONE:
// fall through
default:
@@ -55,16 +58,13 @@ public class Location {
if (o == null || getClass() != o.getClass()) {
return false;
}
-
Location location = (Location) o;
-
if (this.x != location.x) {
return false;
}
if (this.y != location.y) {
return false;
}
-
return true;
}
@@ -74,4 +74,5 @@ public class Location {
result = 31 * result + this.y;
return result;
}
+
}
diff --git a/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/snake/Snake.java b/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/snake/Snake.java
index d19cd4f549e..49a6657951a 100644
--- a/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/snake/Snake.java
+++ b/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/snake/Snake.java
@@ -1,10 +1,9 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Copyright 2012-2018 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@@ -157,4 +156,5 @@ public class Snake {
public String getHexColor() {
return this.hexColor;
}
+
}
diff --git a/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/snake/SnakeTimer.java b/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/snake/SnakeTimer.java
index b8d60600cd1..91cd5540636 100644
--- a/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/snake/SnakeTimer.java
+++ b/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/snake/SnakeTimer.java
@@ -1,10 +1,9 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Copyright 2012-2018 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@@ -25,24 +24,27 @@ import java.util.TimerTask;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
-import org.apache.juli.logging.Log;
-import org.apache.juli.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Sets up the timer for the multi-player snake game WebSocket example.
*/
-public class SnakeTimer {
+public final class SnakeTimer {
private static final long TICK_DELAY = 100;
private static final Object MONITOR = new Object();
- private static final Log log = LogFactory.getLog(SnakeTimer.class);
+ private static final Logger log = LoggerFactory.getLogger(SnakeTimer.class);
private static final ConcurrentHashMap snakes = new ConcurrentHashMap<>();
private static Timer gameTimer = null;
+ private SnakeTimer() {
+ }
+
public static void addSnake(Snake snake) {
synchronized (MONITOR) {
if (snakes.isEmpty()) {
@@ -112,4 +114,5 @@ public class SnakeTimer {
gameTimer.cancel();
}
}
+
}
diff --git a/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/snake/SnakeUtils.java b/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/snake/SnakeUtils.java
index f6ae703060b..44922a92cc1 100644
--- a/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/snake/SnakeUtils.java
+++ b/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/snake/SnakeUtils.java
@@ -1,10 +1,9 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Copyright 2012-2018 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@@ -20,14 +19,28 @@ package samples.websocket.tomcat.snake;
import java.awt.Color;
import java.util.Random;
-public class SnakeUtils {
+public final class SnakeUtils {
+ /**
+ * The width of the playfield.
+ */
public static final int PLAYFIELD_WIDTH = 640;
+
+ /**
+ * The height of the playfield.
+ */
public static final int PLAYFIELD_HEIGHT = 480;
+
+ /**
+ * The grid size.
+ */
public static final int GRID_SIZE = 10;
private static final Random random = new Random();
+ private SnakeUtils() {
+ }
+
public static String getRandomHexColor() {
float hue = random.nextFloat();
// sat between 0.1 and 0.3
diff --git a/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/snake/SnakeWebSocketHandler.java b/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/snake/SnakeWebSocketHandler.java
index 8bdd45e3bc6..4f7565299ff 100644
--- a/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/snake/SnakeWebSocketHandler.java
+++ b/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/snake/SnakeWebSocketHandler.java
@@ -1,10 +1,9 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Copyright 2012-2018 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@@ -29,14 +28,12 @@ import org.springframework.web.socket.handler.TextWebSocketHandler;
public class SnakeWebSocketHandler extends TextWebSocketHandler {
- public static final int PLAYFIELD_WIDTH = 640;
- public static final int PLAYFIELD_HEIGHT = 480;
- public static final int GRID_SIZE = 10;
-
private static final AtomicInteger snakeIds = new AtomicInteger(0);
+
private static final Random random = new Random();
private final int id;
+
private Snake snake;
public static String getRandomHexColor() {
@@ -50,15 +47,15 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler {
}
public static Location getRandomLocation() {
- int x = roundByGridSize(random.nextInt(PLAYFIELD_WIDTH));
- int y = roundByGridSize(random.nextInt(PLAYFIELD_HEIGHT));
+ int x = roundByGridSize(random.nextInt(SnakeUtils.PLAYFIELD_WIDTH));
+ int y = roundByGridSize(random.nextInt(SnakeUtils.PLAYFIELD_HEIGHT));
return new Location(x, y);
}
private static int roundByGridSize(int value) {
- value = value + (GRID_SIZE / 2);
- value = value / GRID_SIZE;
- value = value * GRID_SIZE;
+ value = value + (SnakeUtils.GRID_SIZE / 2);
+ value = value / SnakeUtils.GRID_SIZE;
+ value = value * SnakeUtils.GRID_SIZE;
return value;
}
@@ -109,4 +106,5 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler {
SnakeTimer.broadcast(
String.format("{'type': 'leave', 'id': %d}", Integer.valueOf(this.id)));
}
+
}
diff --git a/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/test/java/samples/websocket/tomcat/snake/SnakeTimerTests.java b/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/test/java/samples/websocket/tomcat/snake/SnakeTimerTests.java
index f8f721d287b..3f7d0bbb920 100644
--- a/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/test/java/samples/websocket/tomcat/snake/SnakeTimerTests.java
+++ b/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/test/java/samples/websocket/tomcat/snake/SnakeTimerTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2017 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,8 +32,8 @@ public class SnakeTimerTests {
Snake snake = mock(Snake.class);
willThrow(new IOException()).given(snake).sendMessage(anyString());
SnakeTimer.addSnake(snake);
-
SnakeTimer.broadcast("");
assertThat(SnakeTimer.getSnakes()).hasSize(0);
}
+
}
diff --git a/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/echo/DefaultEchoService.java b/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/echo/DefaultEchoService.java
index 40d5e67e51b..0326a0a2d79 100644
--- a/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/echo/DefaultEchoService.java
+++ b/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/echo/DefaultEchoService.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2015 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@ public class DefaultEchoService implements EchoService {
private final String echoFormat;
public DefaultEchoService(String echoFormat) {
- this.echoFormat = (echoFormat != null) ? echoFormat : "%s";
+ this.echoFormat = (echoFormat != null ? echoFormat : "%s");
}
@Override
diff --git a/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/reverse/ReverseWebSocketEndpoint.java b/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/reverse/ReverseWebSocketEndpoint.java
index 5b9421366a3..6512fed42b0 100644
--- a/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/reverse/ReverseWebSocketEndpoint.java
+++ b/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/reverse/ReverseWebSocketEndpoint.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2015 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,4 +30,5 @@ public class ReverseWebSocketEndpoint {
session.getBasicRemote()
.sendText("Reversed: " + new StringBuilder(message).reverse());
}
+
}
diff --git a/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/snake/Direction.java b/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/snake/Direction.java
index c3542eaa999..b67728acce7 100644
--- a/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/snake/Direction.java
+++ b/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/snake/Direction.java
@@ -1,10 +1,9 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Copyright 2012-2018 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@@ -18,5 +17,7 @@
package samples.websocket.undertow.snake;
public enum Direction {
+
NONE, NORTH, SOUTH, EAST, WEST
+
}
diff --git a/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/snake/Location.java b/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/snake/Location.java
index ffe1e2dde27..9eb85994fb6 100644
--- a/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/snake/Location.java
+++ b/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/snake/Location.java
@@ -1,10 +1,9 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Copyright 2012-2018 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@@ -19,11 +18,15 @@ package samples.websocket.undertow.snake;
public class Location {
+ /**
+ * The X location.
+ */
public int x;
+
+ /**
+ * The Y location.
+ */
public int y;
- public static final int GRID_SIZE = 10;
- public static final int PLAYFIELD_HEIGHT = 480;
- public static final int PLAYFIELD_WIDTH = 640;
public Location(int x, int y) {
this.x = x;
@@ -33,13 +36,13 @@ public class Location {
public Location getAdjacentLocation(Direction direction) {
switch (direction) {
case NORTH:
- return new Location(this.x, this.y - Location.GRID_SIZE);
+ return new Location(this.x, this.y - SnakeUtils.GRID_SIZE);
case SOUTH:
- return new Location(this.x, this.y + Location.GRID_SIZE);
+ return new Location(this.x, this.y + SnakeUtils.GRID_SIZE);
case EAST:
- return new Location(this.x + Location.GRID_SIZE, this.y);
+ return new Location(this.x + SnakeUtils.GRID_SIZE, this.y);
case WEST:
- return new Location(this.x - Location.GRID_SIZE, this.y);
+ return new Location(this.x - SnakeUtils.GRID_SIZE, this.y);
case NONE:
// fall through
default:
@@ -55,16 +58,13 @@ public class Location {
if (o == null || getClass() != o.getClass()) {
return false;
}
-
Location location = (Location) o;
-
if (this.x != location.x) {
return false;
}
if (this.y != location.y) {
return false;
}
-
return true;
}
@@ -74,4 +74,5 @@ public class Location {
result = 31 * result + this.y;
return result;
}
+
}
diff --git a/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/snake/Snake.java b/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/snake/Snake.java
index 78b6b044b44..a53ccaf1fb3 100644
--- a/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/snake/Snake.java
+++ b/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/snake/Snake.java
@@ -1,10 +1,9 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Copyright 2012-2018 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@@ -157,4 +156,5 @@ public class Snake {
public String getHexColor() {
return this.hexColor;
}
+
}
diff --git a/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/snake/SnakeTimer.java b/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/snake/SnakeTimer.java
index 7c78c3e1df1..e8925f71c29 100644
--- a/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/snake/SnakeTimer.java
+++ b/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/snake/SnakeTimer.java
@@ -1,10 +1,9 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Copyright 2012-2018 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@@ -31,7 +30,7 @@ import org.slf4j.LoggerFactory;
/**
* Sets up the timer for the multi-player snake game WebSocket example.
*/
-public class SnakeTimer {
+public final class SnakeTimer {
private static final long TICK_DELAY = 100;
@@ -43,6 +42,9 @@ public class SnakeTimer {
private static Timer gameTimer = null;
+ private SnakeTimer() {
+ }
+
public static void addSnake(Snake snake) {
synchronized (MONITOR) {
if (snakes.isEmpty()) {
@@ -112,4 +114,5 @@ public class SnakeTimer {
gameTimer.cancel();
}
}
+
}
diff --git a/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/snake/SnakeUtils.java b/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/snake/SnakeUtils.java
index 7fab90d8a10..de3757cb5af 100644
--- a/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/snake/SnakeUtils.java
+++ b/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/snake/SnakeUtils.java
@@ -1,10 +1,9 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Copyright 2012-2018 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@@ -20,14 +19,28 @@ package samples.websocket.undertow.snake;
import java.awt.Color;
import java.util.Random;
-public class SnakeUtils {
+public final class SnakeUtils {
+ /**
+ * The width of the playfield.
+ */
public static final int PLAYFIELD_WIDTH = 640;
+
+ /**
+ * The height of the playfield.
+ */
public static final int PLAYFIELD_HEIGHT = 480;
+
+ /**
+ * The grid size.
+ */
public static final int GRID_SIZE = 10;
private static final Random random = new Random();
+ private SnakeUtils() {
+ }
+
public static String getRandomHexColor() {
float hue = random.nextFloat();
// sat between 0.1 and 0.3
diff --git a/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/snake/SnakeWebSocketHandler.java b/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/snake/SnakeWebSocketHandler.java
index 30557bdfb8f..195fab94d8d 100644
--- a/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/snake/SnakeWebSocketHandler.java
+++ b/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/snake/SnakeWebSocketHandler.java
@@ -1,10 +1,9 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Copyright 2012-2018 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@@ -29,14 +28,12 @@ import org.springframework.web.socket.handler.TextWebSocketHandler;
public class SnakeWebSocketHandler extends TextWebSocketHandler {
- public static final int PLAYFIELD_WIDTH = 640;
- public static final int PLAYFIELD_HEIGHT = 480;
- public static final int GRID_SIZE = 10;
-
private static final AtomicInteger snakeIds = new AtomicInteger(0);
+
private static final Random random = new Random();
private final int id;
+
private Snake snake;
public static String getRandomHexColor() {
@@ -50,15 +47,15 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler {
}
public static Location getRandomLocation() {
- int x = roundByGridSize(random.nextInt(PLAYFIELD_WIDTH));
- int y = roundByGridSize(random.nextInt(PLAYFIELD_HEIGHT));
+ int x = roundByGridSize(random.nextInt(SnakeUtils.PLAYFIELD_WIDTH));
+ int y = roundByGridSize(random.nextInt(SnakeUtils.PLAYFIELD_HEIGHT));
return new Location(x, y);
}
private static int roundByGridSize(int value) {
- value = value + (GRID_SIZE / 2);
- value = value / GRID_SIZE;
- value = value * GRID_SIZE;
+ value = value + (SnakeUtils.GRID_SIZE / 2);
+ value = value / SnakeUtils.GRID_SIZE;
+ value = value * SnakeUtils.GRID_SIZE;
return value;
}
@@ -109,4 +106,5 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler {
SnakeTimer.broadcast(
String.format("{'type': 'leave', 'id': %d}", Integer.valueOf(this.id)));
}
+
}
diff --git a/spring-boot-samples/spring-boot-sample-websocket-undertow/src/test/java/samples/websocket/undertow/snake/SnakeTimerTests.java b/spring-boot-samples/spring-boot-sample-websocket-undertow/src/test/java/samples/websocket/undertow/snake/SnakeTimerTests.java
index 914dfcd9d57..c7d8e935e58 100644
--- a/spring-boot-samples/spring-boot-sample-websocket-undertow/src/test/java/samples/websocket/undertow/snake/SnakeTimerTests.java
+++ b/spring-boot-samples/spring-boot-sample-websocket-undertow/src/test/java/samples/websocket/undertow/snake/SnakeTimerTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2017 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,8 +32,8 @@ public class SnakeTimerTests {
Snake snake = mock(Snake.class);
willThrow(new IOException()).given(snake).sendMessage(anyString());
SnakeTimer.addSnake(snake);
-
SnakeTimer.broadcast("");
assertThat(SnakeTimer.getSnakes()).hasSize(0);
}
+
}