Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/spotbugs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ jobs:
java-version: '8'
distribution: 'temurin'
- name: spotbugs
run: mvn -B -DskipTests clean verify spotbugs:spotbugs
run: mvn -B -Pit -DskipTests clean verify spotbugs:spotbugs
79 changes: 72 additions & 7 deletions ci/spotbugs/exclude.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,30 @@
<Bug pattern="DC_PARTIALLY_CONSTRUCTED"/>
</Match>

<Match>
<Bug pattern="DM_DEFAULT_ENCODING"/>
<Class name="org.apache.servicecomb.demo.jaxrs.server.beanParam.BeanParamTestService"/>
</Match>

<Match>
<Bug pattern="DM_DEFAULT_ENCODING"/>
<Class name="org.apache.servicecomb.it.deploy.Deploys"/>
</Match>

<Match>
<Bug pattern="DM_DEFAULT_ENCODING"/>
<Class name="org.apache.servicecomb.it.testcase.TestParamCodecEdge"/>
</Match>

<Match>
<Bug pattern="DM_DEFAULT_ENCODING"/>
<Class name="org.apache.servicecomb.it.testcase.TestRestServerConfigEdge"/>
</Match>

<Match>
<Bug pattern="DM_EXIT"/>
</Match>

<Match>
<Bug pattern="EC_UNRELATED_TYPES"/>
</Match>
Expand Down Expand Up @@ -115,14 +139,41 @@
<Bug pattern="MS_PKGPROTECT"/>
</Match>

<Match>
<Bug pattern="NM_CLASS_NOT_EXCEPTION"/>
</Match>

<Match>
<Bug pattern="NM_METHOD_NAMING_CONVENTION"/>
</Match>

<Match>
<Bug pattern="NM_SAME_SIMPLE_NAME_AS_SUPERCLASS"/>
</Match>

<Match>
<Bug pattern="NP_NONNULL_PARAM_VIOLATION"/>
<Class name="org.apache.servicecomb.it.testcase.objectparams.TestJAXRSObjectParamType"/>
</Match>

<Match>
<Bug pattern="NP_NONNULL_PARAM_VIOLATION"/>
<Class name="org.apache.servicecomb.it.testcase.objectparams.TestRPCObjectParamType"/>
</Match>

<Match>
<Bug pattern="NP_NONNULL_PARAM_VIOLATION"/>
<Class name="org.apache.servicecomb.it.testcase.objectparams.TestSpringMVCObjectParamType"/>
</Match>

<Match>
<Bug pattern="NP_NONNULL_RETURN_VIOLATION"/>
</Match>

<Match>
<Bug pattern="NP_NULL_ON_SOME_PATH"/>
</Match>

<Match>
<Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"/>
</Match>
Expand All @@ -143,6 +194,11 @@
<Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE"/>
</Match>

<Match>
<Bug pattern="REC_CATCH_EXCEPTION"/>
<Class name="org.apache.servicecomb.demo.springmvc.SpringmvcClient"/>
</Match>

<Match>
<Bug pattern="REFLC_REFLECTION_MAY_INCREASE_ACCESSIBILITY_OF_CLASS"/>
</Match>
Expand All @@ -151,10 +207,19 @@
<Bug pattern="RV_NEGATING_RESULT_OF_COMPARETO"/>
</Match>

<Match>
<Bug pattern="RV_RETURN_VALUE_IGNORED"/>
</Match>

<Match>
<Bug pattern="SE_BAD_FIELD"/>
</Match>

<Match>
<Bug pattern="SR_NOT_CHECKED"/>
<Class name="org.apache.servicecomb.demo.springmvc.client.ConsumerTestsAfterBootup"/>
</Match>

<Match>
<Bug pattern="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD"/>
</Match>
Expand All @@ -168,31 +233,31 @@
</Match>

<Match>
<Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"/>
<Bug pattern="THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION"/>
</Match>

<Match>
<Bug pattern="UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD"/>
<Bug pattern="THROWS_METHOD_THROWS_CLAUSE_THROWABLE"/>
</Match>

<Match>
<Bug pattern="UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD"/>
<Bug pattern="THROWS_METHOD_THROWS_RUNTIMEEXCEPTION"/>
</Match>

<Match>
<Bug pattern="VA_FORMAT_STRING_USES_NEWLINE"/>
<Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"/>
</Match>

<Match>
<Bug pattern="THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION"/>
<Bug pattern="UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD"/>
</Match>

<Match>
<Bug pattern="THROWS_METHOD_THROWS_CLAUSE_THROWABLE"/>
<Bug pattern="UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD"/>
</Match>

<Match>
<Bug pattern="THROWS_METHOD_THROWS_RUNTIMEEXCEPTION"/>
<Bug pattern="VA_FORMAT_STRING_USES_NEWLINE"/>
</Match>

</FindBugsFilter>
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ interface RetrySchemaInf {

RestTemplate restTemplate = RestTemplateBuilder.create();

final String server = "servicecomb://filterServer";
private static final String SERVER = "servicecomb://filterServer";

@Override
public void testAllTransport() throws Exception {
Expand All @@ -55,7 +55,7 @@ private void testRetryGovernanceRpc() throws Exception {
}

private void testRetryGovernanceRestTemplate() {
TestMgr.check(restTemplate.getForObject(server + "/retry/governance/successWhenRetry", boolean.class), true);
TestMgr.check(restTemplate.getForObject(server + "/retry/governance/successWhenRetry", boolean.class), true);
TestMgr.check(restTemplate.getForObject(SERVER + "/retry/governance/successWhenRetry", boolean.class), true);
TestMgr.check(restTemplate.getForObject(SERVER + "/retry/governance/successWhenRetry", boolean.class), true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;

import org.apache.servicecomb.demo.CategorizedTestCase;
import org.apache.servicecomb.demo.TestMgr;
Expand Down Expand Up @@ -58,9 +59,9 @@ private void testBeanParam() {
}

private void testUpload() {
BufferedInputStream bufferedInputStream0 = new BufferedInputStream(new ByteArrayInputStream("up0".getBytes()));
BufferedInputStream bufferedInputStream1 = new BufferedInputStream(new ByteArrayInputStream("up1".getBytes()));
BufferedInputStream bufferedInputStream2 = new BufferedInputStream(new ByteArrayInputStream("up2".getBytes()));
BufferedInputStream bufferedInputStream0 = new BufferedInputStream(new ByteArrayInputStream("up0".getBytes(StandardCharsets.UTF_8)));
BufferedInputStream bufferedInputStream1 = new BufferedInputStream(new ByteArrayInputStream("up1".getBytes(StandardCharsets.UTF_8)));
BufferedInputStream bufferedInputStream2 = new BufferedInputStream(new ByteArrayInputStream("up2".getBytes(StandardCharsets.UTF_8)));

String result = beanParamTestServiceIntf.beanParameterTestUpload(
bufferedInputStream0, "queryTest", bufferedInputStream1, bufferedInputStream2, "ex");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;

Expand Down Expand Up @@ -76,9 +77,9 @@ private void testBeanParam() {
}

private void testUpload() {
BufferedInputStream bufferedInputStream0 = new BufferedInputStream(new ByteArrayInputStream("up0".getBytes()));
BufferedInputStream bufferedInputStream1 = new BufferedInputStream(new ByteArrayInputStream("up1".getBytes()));
BufferedInputStream bufferedInputStream2 = new BufferedInputStream(new ByteArrayInputStream("up2".getBytes()));
BufferedInputStream bufferedInputStream0 = new BufferedInputStream(new ByteArrayInputStream("up0".getBytes(StandardCharsets.UTF_8)));
BufferedInputStream bufferedInputStream1 = new BufferedInputStream(new ByteArrayInputStream("up1".getBytes(StandardCharsets.UTF_8)));
BufferedInputStream bufferedInputStream2 = new BufferedInputStream(new ByteArrayInputStream("up2".getBytes(StandardCharsets.UTF_8)));

HashMap<String, Object> formData = new HashMap<>();
formData.put("up0", bufferedInputStream0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public Person sayHello(Person user) {
public String testRawJsonString(String jsonInput) {
Map<String, String> person;
try {
person = RestObjectMapperFactory.getRestObjectMapper().readValue(jsonInput.getBytes(), Map.class);
person = RestObjectMapperFactory.getRestObjectMapper().readValue(jsonInput.getBytes(StandardCharsets.UTF_8), Map.class);
} catch (Exception e) {
e.printStackTrace();
return null;
Expand Down Expand Up @@ -187,11 +187,11 @@ public boolean isTrue() {
@DELETE
@Produces(MediaType.TEXT_PLAIN)
public String addString(@QueryParam("s") List<String> s) {
String result = "";
StringBuilder result = new StringBuilder();
for (String x : s) {
result += x;
result.append(x);
}
return result;
return result.toString();
}

@Path("/ignore")
Expand All @@ -209,7 +209,7 @@ public OutputModelForTestIgnore testModelWithIgnoreField(InputModelForTestIgnore
public String testRawJsonAnnotation(@RawJsonRequestBody String jsonInput) {
Map<String, String> person;
try {
person = RestObjectMapperFactory.getRestObjectMapper().readValue(jsonInput.getBytes(), Map.class);
person = RestObjectMapperFactory.getRestObjectMapper().readValue(jsonInput.getBytes(StandardCharsets.UTF_8), Map.class);
} catch (Exception e) {
e.printStackTrace();
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.servicecomb.demo.jaxrs.server;

import java.nio.charset.StandardCharsets;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
Expand Down Expand Up @@ -73,7 +74,7 @@ public Person sayHello(Person user) {
public String testRawJsonString(String jsonInput) {
Map<String, String> person;
try {
person = RestObjectMapperFactory.getRestObjectMapper().readValue(jsonInput.getBytes(), Map.class);
person = RestObjectMapperFactory.getRestObjectMapper().readValue(jsonInput.getBytes(StandardCharsets.UTF_8), Map.class);
} catch (Exception e) {
e.printStackTrace();
return null;
Expand Down Expand Up @@ -116,10 +117,10 @@ public boolean isTrue() {
@DELETE
@Produces(MediaType.TEXT_PLAIN)
public String addString(@QueryParam("s") String[] s) {
String result = "";
StringBuilder result = new StringBuilder();
for (String x : s) {
result += x;
result.append(x);
}
return result;
return result.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ public class LocalRegistryServerTest implements CategorizedTestCase {
@RpcReference(microserviceName = "demo-local-registry-server-bean2", schemaId = "CodeFirstEndpoint2")
private CodeFirstService codeFirstServiceBean2;

RestTemplate template = RestTemplateBuilder.create();

@Override
public void testRestTransport() throws Exception {
testServerGetName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ private void testWrappedModel() {
data.put(100L, model);

List<AbstractModel> data2 = new ArrayList<>();

AbstractModel model2 = new DefaultAbstractModel();
model2.setName("hello");
data2.add(model);
data2.add(model2);

WrappedAbstractModel input = new WrappedAbstractModel();
input.setMapModel(data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ public boolean isTrue() {
}

public String addString(List<String> s) {
String result = "";
StringBuilder result = new StringBuilder();
for (String x : s) {
result += x;
result.append(x);
}
return result;
return result.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ interface RetrySchemaInf {

RestTemplate restTemplate = RestTemplateBuilder.create();

final String server = "servicecomb://springmvc";
private static final String SERVER = "servicecomb://springmvc";

@Override
public void testAllTransport() throws Exception {
Expand All @@ -55,7 +55,7 @@ private void testRetryGovernanceRpc() throws Exception {
}

private void testRetryGovernanceRestTemplate() {
TestMgr.check(restTemplate.getForObject(server + "/retry/governance/successWhenRetry", boolean.class), true);
TestMgr.check(restTemplate.getForObject(server + "/retry/governance/successWhenRetry", boolean.class), true);
TestMgr.check(restTemplate.getForObject(SERVER + "/retry/governance/successWhenRetry", boolean.class), true);
TestMgr.check(restTemplate.getForObject(SERVER + "/retry/governance/successWhenRetry", boolean.class), true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public Person sayHello(@RequestBody Person user) {
public String testRawJsonString(String jsonInput) {
Map<String, String> person;
try {
person = RestObjectMapperFactory.getRestObjectMapper().readValue(jsonInput.getBytes(), Map.class);
person = RestObjectMapperFactory.getRestObjectMapper().readValue(jsonInput.getBytes(StandardCharsets.UTF_8), Map.class);
} catch (Exception e) {
e.printStackTrace();
return null;
Expand Down Expand Up @@ -283,11 +283,11 @@ public boolean isTrue() {

@DeleteMapping(path = "/addstring", produces = MediaType.TEXT_PLAIN_VALUE)
public String addString(@RequestParam(name = "s") List<String> s) {
String result = "";
StringBuilder result = new StringBuilder();
for (String x : s) {
result += x;
result.append(x);
}
return result;
return result.toString();
}

// Using 490, 590 error code, the response type should be CommonExceptionData. Or we need
Expand Down Expand Up @@ -360,7 +360,7 @@ public OutputModelForTestIgnore testModelWithIgnoreField(@RequestBody InputModel
public String testRawJsonAnnotation(@RawJsonRequestBody String jsonInput) {
Map<String, String> person;
try {
person = RestObjectMapperFactory.getRestObjectMapper().readValue(jsonInput.getBytes(), Map.class);
person = RestObjectMapperFactory.getRestObjectMapper().readValue(jsonInput.getBytes(StandardCharsets.UTF_8), Map.class);
} catch (Exception e) {
e.printStackTrace();
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.TimeUnit;

import org.apache.servicecomb.core.SCBEngine;
Expand Down Expand Up @@ -49,7 +50,7 @@ public void run() {
}

private void doRun() throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8));
String line;
while ((line = reader.readLine()) != null) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.File;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.List;

Expand Down Expand Up @@ -55,7 +56,7 @@ public void deploy() throws Throwable {
this.prevFailCount = ITJUnitUtils.getFailures().size();
LOGGER.info("createProcessBuilder: " + StringUtils.join(cmds, " ") + "\nWorkDir: " + deployDefinition.getWorkDir());
subProcess = createProcessBuilder(cmds).start();
subProcessCommandWriter = new BufferedWriter(new OutputStreamWriter(subProcess.getOutputStream()));
subProcessCommandWriter = new BufferedWriter(new OutputStreamWriter(subProcess.getOutputStream(), StandardCharsets.UTF_8));
subProcessLogger = new SubProcessLogger(deployDefinition.getDisplayName(), subProcess.getInputStream(),
deployDefinition.getStartCompleteLog());
}
Expand Down
Loading