Skip to content

Commit a78ac2c

Browse files
committed
Make everything nonnull by default
1 parent 3b3feac commit a78ac2c

File tree

39 files changed

+612
-25
lines changed

39 files changed

+612
-25
lines changed

apm-agent-benchmarks/src/main/java/co/elastic/apm/impl/HttpMoshiReporterBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*/
2020
package co.elastic.apm.impl;
2121

22-
import co.elastic.apm.impl.serialize.MoshiPayloadSerializer;
22+
import co.elastic.apm.report.serialize.MoshiPayloadSerializer;
2323
import co.elastic.apm.report.serialize.PayloadSerializer;
2424
import org.openjdk.jmh.profile.GCProfiler;
2525
import org.openjdk.jmh.runner.Runner;
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77
* Licensed under the Apache License, Version 2.0 (the "License");
88
* you may not use this file except in compliance with the License.
99
* You may obtain a copy of the License at
10-
*
10+
*
1111
* http://www.apache.org/licenses/LICENSE-2.0
12-
*
12+
*
1313
* Unless required by applicable law or agreed to in writing, software
1414
* distributed under the License is distributed on an "AS IS" BASIS,
1515
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1616
* See the License for the specific language governing permissions and
1717
* limitations under the License.
1818
* #L%
1919
*/
20-
package co.elastic.apm.impl.serialize;
20+
package co.elastic.apm.report.serialize;
2121

2222
import co.elastic.apm.impl.payload.Payload;
2323
import co.elastic.apm.report.serialize.PayloadSerializer;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*-
2+
* #%L
3+
* Elastic APM Java agent
4+
* %%
5+
* Copyright (C) 2018 the original author or authors
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package co.elastic.apm.annotation;
21+
22+
import javax.annotation.Nonnull;
23+
import javax.annotation.meta.TypeQualifierDefault;
24+
import java.lang.annotation.ElementType;
25+
import java.lang.annotation.Retention;
26+
import java.lang.annotation.RetentionPolicy;
27+
28+
@Nonnull
29+
@TypeQualifierDefault({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
30+
@Retention(RetentionPolicy.RUNTIME)
31+
public @interface NonnullApi {
32+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*-
2+
* #%L
3+
* Elastic APM Java agent
4+
* %%
5+
* Copyright (C) 2018 the original author or authors
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
@NonnullApi
21+
package co.elastic.apm.annotation;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*-
2+
* #%L
3+
* Elastic APM Java agent
4+
* %%
5+
* Copyright (C) 2018 the original author or authors
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
@NonnullApi
21+
package co.elastic.apm.api;
22+
23+
import co.elastic.apm.annotation.NonnullApi;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*-
2+
* #%L
3+
* Elastic APM Java agent
4+
* %%
5+
* Copyright (C) 2018 the original author or authors
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
@NonnullApi
21+
package co.elastic.apm.configuration;
22+
23+
import co.elastic.apm.annotation.NonnullApi;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*-
2+
* #%L
3+
* Elastic APM Java agent
4+
* %%
5+
* Copyright (C) 2018 the original author or authors
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
@NonnullApi
21+
package co.elastic.apm.configuration.validation;
22+
23+
import co.elastic.apm.annotation.NonnullApi;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*-
2+
* #%L
3+
* Elastic APM Java agent
4+
* %%
5+
* Copyright (C) 2018 the original author or authors
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
@NonnullApi
21+
package co.elastic.apm.context;
22+
23+
import co.elastic.apm.annotation.NonnullApi;

apm-agent-core/src/main/java/co/elastic/apm/impl/ElasticApmTracer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import org.stagemonitor.configuration.ConfigurationRegistry;
4848

4949
import javax.annotation.Nonnull;
50+
import javax.annotation.Nullable;
5051
import java.util.concurrent.TimeUnit;
5152

5253
/**
@@ -243,7 +244,7 @@ public void endTransaction(Transaction transaction) {
243244
currentTransaction.clear();
244245
}
245246

246-
private boolean isNoop(Transaction transaction) {
247+
private boolean isNoop(@Nullable Transaction transaction) {
247248
return transaction == noopTransaction;
248249
}
249250

apm-agent-core/src/main/java/co/elastic/apm/impl/context/Request.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public class Request implements Recyclable {
8181
* Data should only contain the request body (not the query string). It can either be a dictionary (for standard HTTP requests) or a raw request body.
8282
*/
8383
@JsonProperty("body")
84+
@Nullable
8485
public Object getBody() {
8586
if (!postParams.isEmpty()) {
8687
return postParams;

0 commit comments

Comments
 (0)