Skip to content

Commit 8978f7e

Browse files
committed
Enable checkstyle on main sources
Closes gh-1479
2 parents 34583e2 + 17c4dd4 commit 8978f7e

File tree

524 files changed

+5138
-4892
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

524 files changed

+5138
-4892
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright 2005-2025 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.ws.gradle.conventions;
18+
19+
import io.spring.javaformat.gradle.SpringJavaFormatPlugin;
20+
import org.gradle.api.Plugin;
21+
import org.gradle.api.Project;
22+
import org.gradle.api.artifacts.DependencySet;
23+
import org.gradle.api.plugins.JavaPlugin;
24+
import org.gradle.api.plugins.quality.Checkstyle;
25+
import org.gradle.api.plugins.quality.CheckstyleExtension;
26+
import org.gradle.api.plugins.quality.CheckstylePlugin;
27+
28+
/**
29+
* {@link Plugin} that applies conventions for checkstyle.
30+
*
31+
* @author Brian Clozel
32+
* @author Stephane Nicoll
33+
*/
34+
public class CheckstyleConventions {
35+
36+
/**
37+
* Applies the Spring Java Format and Checkstyle plugins with the project conventions.
38+
* @param project the current project
39+
*/
40+
public void apply(Project project) {
41+
project.getPlugins().withType(JavaPlugin.class, (java) -> {
42+
project.getPlugins().apply(CheckstylePlugin.class);
43+
project.getTasks().withType(Checkstyle.class).forEach(checkstyle -> checkstyle.getMaxHeapSize().set("1g"));
44+
project.getTasks().named("checkstyleTest").configure(task -> task.setEnabled(false));
45+
CheckstyleExtension checkstyle = project.getExtensions().getByType(CheckstyleExtension.class);
46+
checkstyle.setToolVersion("10.21.1");
47+
checkstyle.getConfigDirectory().set(project.getRootProject().file("src/checkstyle"));
48+
String version = SpringJavaFormatPlugin.class.getPackage().getImplementationVersion();
49+
DependencySet checkstyleDependencies = project.getConfigurations()
50+
.getByName("checkstyle")
51+
.getDependencies();
52+
checkstyleDependencies.add(
53+
project.getDependencies().create("com.puppycrawl.tools:checkstyle:" + checkstyle.getToolVersion()));
54+
checkstyleDependencies
55+
.add(project.getDependencies().create("io.spring.javaformat:spring-javaformat-checkstyle:" + version));
56+
});
57+
}
58+
59+
}

gradle/plugins/conventions-plugin/src/main/java/org/springframework/ws/gradle/conventions/ConventionsPlugin.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ public class ConventionsPlugin implements Plugin<Project> {
3333
@Override
3434
public void apply(Project project) {
3535
project.setGroup("org.springframework.ws");
36-
project.getPlugins()
37-
.withType(JavaBasePlugin.class)
38-
.all((plugin) -> new JavaBasePluginConventions().apply(project));
36+
project.getPlugins().withType(JavaBasePlugin.class).all((plugin) -> {
37+
new JavaBasePluginConventions().apply(project);
38+
new CheckstyleConventions().apply(project);
39+
});
3940
project.getPlugins().withType(JavaPlugin.class).all((plugin) -> new JavaPluginConventions().apply(project));
4041
project.getPlugins()
4142
.withType(MavenPublishPlugin.class)

spring-ws-core/src/main/java/org/springframework/ws/FaultAwareWebServiceMessage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
* often require different processing rules.
2525
*
2626
* @author Arjen Poutsma
27-
* @see org.springframework.ws.soap.SoapMessage
2827
* @since 1.0.0
28+
* @see org.springframework.ws.soap.SoapMessage
2929
*/
3030
public interface FaultAwareWebServiceMessage extends WebServiceMessage {
3131

spring-ws-core/src/main/java/org/springframework/ws/WebServiceMessage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
* Contains methods that provide access to the payload of the message.
2929
*
3030
* @author Arjen Poutsma
31+
* @since 1.0.0
3132
* @see org.springframework.ws.soap.SoapMessage
3233
* @see WebServiceMessageFactory
33-
* @since 1.0.0
3434
*/
3535
public interface WebServiceMessage {
3636

spring-ws-core/src/main/java/org/springframework/ws/WebServiceMessageFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
* Allows the creation of empty messages, or messages based on {@code InputStream}s.
2727
*
2828
* @author Arjen Poutsma
29-
* @see org.springframework.ws.WebServiceMessage
3029
* @since 1.0.0
30+
* @see org.springframework.ws.WebServiceMessage
3131
*/
3232
public interface WebServiceMessageFactory {
3333

spring-ws-core/src/main/java/org/springframework/ws/client/WebServiceFaultException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class WebServiceFaultException extends WebServiceClientException {
3232
/** Create a new instance of the {@code WebServiceFaultException} class. */
3333
public WebServiceFaultException(String msg) {
3434
super(msg);
35-
faultMessage = null;
35+
this.faultMessage = null;
3636
}
3737

3838
/**
@@ -46,7 +46,7 @@ public WebServiceFaultException(FaultAwareWebServiceMessage faultMessage) {
4646

4747
/** Returns the fault message. */
4848
public FaultAwareWebServiceMessage getWebServiceMessage() {
49-
return faultMessage;
49+
return this.faultMessage;
5050
}
5151

5252
}

spring-ws-core/src/main/java/org/springframework/ws/client/core/SimpleFaultMessageResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
* fault occurs.
2626
*
2727
* @author Arjen Poutsma
28-
* @see WebServiceFaultException
2928
* @since 1.0.0
29+
* @see WebServiceFaultException
3030
*/
3131
public class SimpleFaultMessageResolver implements FaultMessageResolver {
3232

spring-ws-core/src/main/java/org/springframework/ws/client/core/SourceExtractor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@
3434
* Implementations of this interface perform the actual work of extracting results, but
3535
* don't need to worry about exception handling, or resource handling.
3636
*
37+
* @param <T> the type of the source
3738
* @author Arjen Poutsma
38-
* @see org.springframework.ws.client.core.WebServiceTemplate
3939
* @since 1.0.0
40+
* @see org.springframework.ws.client.core.WebServiceTemplate
4041
*/
4142
public interface SourceExtractor<T> {
4243

spring-ws-core/src/main/java/org/springframework/ws/client/core/WebServiceMessageExtractor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
* Implementations of this interface perform the actual work of extracting results, but
3636
* don't need to worry about exception handling, or resource handling.
3737
*
38+
* @param <T> the type of the result object
3839
* @author Arjen Poutsma
3940
* @since 1.0.0
4041
*/

spring-ws-core/src/main/java/org/springframework/ws/client/core/WebServiceOperations.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
* testability, as it can easily be mocked or stubbed.
2929
*
3030
* @author Arjen Poutsma
31-
* @see WebServiceTemplate
3231
* @since 1.0.0
32+
* @see WebServiceTemplate
3333
*/
3434
public interface WebServiceOperations {
3535

spring-ws-core/src/main/java/org/springframework/ws/client/core/WebServiceTemplate.java

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,9 @@ public WebServiceTemplate(Marshaller marshaller, Unmarshaller unmarshaller) {
206206
* Returns the default URI to be used on operations that do not have a URI parameter.
207207
*/
208208
public String getDefaultUri() {
209-
if (destinationProvider != null) {
210-
URI uri = destinationProvider.getDestination();
211-
return uri != null ? uri.toString() : null;
209+
if (this.destinationProvider != null) {
210+
URI uri = this.destinationProvider.getDestination();
211+
return (uri != null) ? uri.toString() : null;
212212
}
213213
else {
214214
return null;
@@ -229,7 +229,7 @@ public String getDefaultUri() {
229229
* @see #sendAndReceive(WebServiceMessageCallback,WebServiceMessageCallback)
230230
*/
231231
public void setDefaultUri(final String uri) {
232-
destinationProvider = new DestinationProvider() {
232+
this.destinationProvider = new DestinationProvider() {
233233

234234
public URI getDestination() {
235235
return URI.create(uri);
@@ -242,7 +242,7 @@ public URI getDestination() {
242242
* parameter.
243243
*/
244244
public DestinationProvider getDestinationProvider() {
245-
return destinationProvider;
245+
return this.destinationProvider;
246246
}
247247

248248
/**
@@ -265,7 +265,7 @@ public void setDestinationProvider(DestinationProvider destinationProvider) {
265265

266266
/** Returns the marshaller for this template. */
267267
public Marshaller getMarshaller() {
268-
return marshaller;
268+
return this.marshaller;
269269
}
270270

271271
/** Sets the marshaller for this template. */
@@ -275,7 +275,7 @@ public void setMarshaller(Marshaller marshaller) {
275275

276276
/** Returns the unmarshaller for this template. */
277277
public Unmarshaller getUnmarshaller() {
278-
return unmarshaller;
278+
return this.unmarshaller;
279279
}
280280

281281
/** Sets the unmarshaller for this template. */
@@ -285,7 +285,7 @@ public void setUnmarshaller(Unmarshaller unmarshaller) {
285285

286286
/** Returns the fault message resolver for this template. */
287287
public FaultMessageResolver getFaultMessageResolver() {
288-
return faultMessageResolver;
288+
return this.faultMessageResolver;
289289
}
290290

291291
/**
@@ -347,7 +347,7 @@ public void setCheckConnectionForFault(boolean checkConnectionForFault) {
347347
* @return array of endpoint interceptors, or {@code null} if none
348348
*/
349349
public ClientInterceptor[] getInterceptors() {
350-
return interceptors;
350+
return this.interceptors;
351351
}
352352

353353
/**
@@ -613,10 +613,10 @@ protected <T> T doSendAndReceive(MessageContext messageContext, WebServiceConnec
613613
}
614614
// Apply handleRequest of registered interceptors
615615
boolean intercepted = false;
616-
if (interceptors != null) {
617-
for (int i = 0; i < interceptors.length; i++) {
616+
if (this.interceptors != null) {
617+
for (int i = 0; i < this.interceptors.length; i++) {
618618
interceptorIndex = i;
619-
if (!interceptors[i].handleRequest(messageContext)) {
619+
if (!this.interceptors[i].handleRequest(messageContext)) {
620620
intercepted = true;
621621
break;
622622
}
@@ -687,9 +687,9 @@ else if (sentMessageTracingLogger.isDebugEnabled()) {
687687
* @throws IOException in case of I/O errors
688688
*/
689689
protected boolean hasError(WebServiceConnection connection, WebServiceMessage request) throws IOException {
690-
if (checkConnectionForError && connection.hasError()) {
690+
if (this.checkConnectionForError && connection.hasError()) {
691691
// could be a fault
692-
if (checkConnectionForFault && connection instanceof FaultAwareWebServiceConnection faultConnection) {
692+
if (this.checkConnectionForFault && connection instanceof FaultAwareWebServiceConnection faultConnection) {
693693
return !(faultConnection.hasFault() && request instanceof FaultAwareWebServiceMessage);
694694
}
695695
else {
@@ -709,8 +709,8 @@ protected boolean hasError(WebServiceConnection connection, WebServiceMessage re
709709
* if any
710710
*/
711711
protected Object handleError(WebServiceConnection connection, WebServiceMessage request) throws IOException {
712-
if (logger.isDebugEnabled()) {
713-
logger.debug("Received error for request [" + request + "]");
712+
if (this.logger.isDebugEnabled()) {
713+
this.logger.debug("Received error for request [" + request + "]");
714714
}
715715
throw new WebServiceTransportException(connection.getErrorMessage());
716716
}
@@ -754,7 +754,7 @@ else if (receivedMessageTracingLogger.isDebugEnabled()) {
754754
* @throws IOException in case of I/O errors
755755
*/
756756
protected boolean hasFault(WebServiceConnection connection, WebServiceMessage response) throws IOException {
757-
if (checkConnectionForFault && connection instanceof FaultAwareWebServiceConnection faultConnection) {
757+
if (this.checkConnectionForFault && connection instanceof FaultAwareWebServiceConnection faultConnection) {
758758
// check whether the connection has a fault (i.e. status code 500 in HTTP)
759759
if (!faultConnection.hasFault()) {
760760
return false;
@@ -778,9 +778,9 @@ protected boolean hasFault(WebServiceConnection connection, WebServiceMessage re
778778
* @see ClientInterceptor#handleFault(MessageContext)
779779
*/
780780
private void triggerHandleResponse(int interceptorIndex, MessageContext messageContext) {
781-
if (messageContext.hasResponse() && interceptors != null) {
781+
if (messageContext.hasResponse() && this.interceptors != null) {
782782
for (int i = interceptorIndex; i >= 0; i--) {
783-
if (!interceptors[i].handleResponse(messageContext)) {
783+
if (!this.interceptors[i].handleResponse(messageContext)) {
784784
break;
785785
}
786786
}
@@ -797,9 +797,9 @@ private void triggerHandleResponse(int interceptorIndex, MessageContext messageC
797797
* @see ClientInterceptor#handleFault(MessageContext)
798798
*/
799799
private void triggerHandleFault(int interceptorIndex, MessageContext messageContext) {
800-
if (messageContext.hasResponse() && interceptors != null) {
800+
if (messageContext.hasResponse() && this.interceptors != null) {
801801
for (int i = interceptorIndex; i >= 0; i--) {
802-
if (!interceptors[i].handleFault(messageContext)) {
802+
if (!this.interceptors[i].handleFault(messageContext)) {
803803
break;
804804
}
805805
}
@@ -813,14 +813,14 @@ private void triggerHandleFault(int interceptorIndex, MessageContext messageCont
813813
* returned {@code false}.
814814
* @param interceptorIndex index of last interceptor that successfully completed
815815
* @param messageContext the message context
816-
* @param ex Exception thrown on handler execution, or {@code null} if none
816+
* @param ex exception thrown on handler execution, or {@code null} if none
817817
* @see ClientInterceptor#afterCompletion
818818
*/
819819
private void triggerAfterCompletion(int interceptorIndex, MessageContext messageContext, Exception ex)
820820
throws WebServiceClientException {
821-
if (interceptors != null) {
821+
if (this.interceptors != null) {
822822
for (int i = interceptorIndex; i >= 0; i--) {
823-
interceptors[i].afterCompletion(messageContext, ex);
823+
this.interceptors[i].afterCompletion(messageContext, ex);
824824
}
825825
}
826826
}
@@ -836,8 +836,8 @@ private void triggerAfterCompletion(int interceptorIndex, MessageContext message
836836
* if any
837837
*/
838838
protected Object handleFault(WebServiceConnection connection, MessageContext messageContext) throws IOException {
839-
if (logger.isDebugEnabled()) {
840-
logger.debug("Received Fault message for request [" + messageContext.getRequest() + "]");
839+
if (this.logger.isDebugEnabled()) {
840+
this.logger.debug("Received Fault message for request [" + messageContext.getRequest() + "]");
841841
}
842842
if (getFaultMessageResolver() != null) {
843843
getFaultMessageResolver().resolveFault(messageContext.getResponse());
@@ -852,7 +852,8 @@ protected Object handleFault(WebServiceConnection connection, MessageContext mes
852852
* Adapter to enable use of a WebServiceMessageCallback inside a
853853
* WebServiceMessageExtractor.
854854
*/
855-
private static class WebServiceMessageCallbackMessageExtractor implements WebServiceMessageExtractor<Boolean> {
855+
private static final class WebServiceMessageCallbackMessageExtractor
856+
implements WebServiceMessageExtractor<Boolean> {
856857

857858
private final WebServiceMessageCallback callback;
858859

@@ -862,14 +863,14 @@ private WebServiceMessageCallbackMessageExtractor(WebServiceMessageCallback call
862863

863864
@Override
864865
public Boolean extractData(WebServiceMessage message) throws IOException, TransformerException {
865-
callback.doWithMessage(message);
866+
this.callback.doWithMessage(message);
866867
return Boolean.TRUE;
867868
}
868869

869870
}
870871

871872
/** Adapter to enable use of a SourceExtractor inside a WebServiceMessageExtractor. */
872-
private static class SourceExtractorMessageExtractor<T> implements WebServiceMessageExtractor<T> {
873+
private static final class SourceExtractorMessageExtractor<T> implements WebServiceMessageExtractor<T> {
873874

874875
private final SourceExtractor<T> sourceExtractor;
875876

@@ -879,7 +880,7 @@ private SourceExtractorMessageExtractor(SourceExtractor<T> sourceExtractor) {
879880

880881
@Override
881882
public T extractData(WebServiceMessage message) throws IOException, TransformerException {
882-
return sourceExtractor.extractData(message.getPayloadSource());
883+
return this.sourceExtractor.extractData(message.getPayloadSource());
883884
}
884885

885886
}

0 commit comments

Comments
 (0)