Skip to content

Commit 2a6c04a

Browse files
Copilotandimarek
andcommitted
Address code review feedback: fix comment, restore license, add nullable to environment params
Co-authored-by: andimarek <1706744+andimarek@users.noreply.github.com>
1 parent 34185f8 commit 2a6c04a

File tree

5 files changed

+67
-43
lines changed

5 files changed

+67
-43
lines changed

JSPECIFY_MIGRATION_PLAN.md

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -46,86 +46,89 @@ The following files already have `@NullMarked` annotations:
4646

4747
## Files Requiring Annotations
4848

49+
> **✅ COMPLETED**: All phases have been implemented. See status below.
50+
4951
### Phase 1: Core Package (`org.dataloader`) - High Priority
5052

5153
| File | Status | Notes |
5254
|------|--------|-------|
53-
| `Try.java` | ❌ Needs annotation | Generic type `V` may be nullable; internal throwable field is nullable |
54-
| `DataLoaderOptions.java` | ❌ Needs annotation | Many nullable fields (cacheKeyFunction, cacheMap, valueCache, batchLoaderScheduler) |
55+
| `Try.java` | ✅ Done | Added `@NullMarked`, marked throwable field as nullable, used `nonNull()` assertions |
56+
| `DataLoaderOptions.java` | ✅ Done | Added `@NullMarked`, marked nullable fields and builder setters |
57+
| `BatchLoaderContextProvider.java` | ✅ Done | Marked `getContext()` return as `@Nullable` |
5558

5659
### Phase 2: Implementation Package (`org.dataloader.impl`)
5760

5861
| File | Status | Notes |
5962
|------|--------|-------|
60-
| `Assertions.java` | ❌ Needs annotation | `nonNull()` method accepts nullable input, returns non-null |
61-
| `CompletableFutureKit.java` | ❌ Needs annotation | Review for nullable handling |
62-
| `PromisedValues.java` | ❌ Needs annotation | Interface with nullable considerations |
63-
| `PromisedValuesImpl.java` | ❌ Needs annotation | Implementation class |
64-
| `NoOpValueCache.java` | ❌ Needs annotation | Implements `ValueCache` |
65-
| `DataLoaderAssertionException.java` | ❌ Needs annotation | Exception class |
63+
| `Assertions.java` | ✅ Done | Added `@NullMarked`, marked `nonNull()` input parameter as nullable |
64+
| `CompletableFutureKit.java` | ✅ Done | Added `@NullMarked`, marked `cause()` return as nullable |
65+
| `PromisedValues.java` | ✅ Done | Added `@NullMarked`, marked nullable returns (`cause()`, `get()`) |
66+
| `PromisedValuesImpl.java` | ✅ Done | Added `@NullMarked`, marked nullable returns |
67+
| `NoOpValueCache.java` | ✅ Done | Added `@NullMarked`, added nullable type bound `V extends @Nullable Object` |
68+
| `DataLoaderAssertionException.java` | ✅ Done | Added `@NullMarked` |
6669

6770
### Phase 3: Statistics Package (`org.dataloader.stats`)
6871

6972
| File | Status | Notes |
7073
|------|--------|-------|
71-
| `Statistics.java` | ❌ Needs annotation | Simple data class, likely all non-null |
72-
| `StatisticsCollector.java` | ❌ Needs annotation | Interface |
73-
| `SimpleStatisticsCollector.java` | ❌ Needs annotation | Implements `StatisticsCollector` |
74-
| `ThreadLocalStatisticsCollector.java` | ❌ Needs annotation | Implements `StatisticsCollector` |
75-
| `NoOpStatisticsCollector.java` | ❌ Needs annotation | Implements `StatisticsCollector` |
76-
| `DelegatingStatisticsCollector.java` | ❌ Needs annotation | Implements `StatisticsCollector` |
74+
| `Statistics.java` | ✅ Done | Added `@NullMarked` |
75+
| `StatisticsCollector.java` | ✅ Done | Added `@NullMarked`, marked context parameters as nullable |
76+
| `SimpleStatisticsCollector.java` | ✅ Done | Added `@NullMarked` |
77+
| `ThreadLocalStatisticsCollector.java` | ✅ Done | Added `@NullMarked` |
78+
| `NoOpStatisticsCollector.java` | ✅ Done | Added `@NullMarked` |
79+
| `DelegatingStatisticsCollector.java` | ✅ Done | Added `@NullMarked` |
7780

7881
#### Statistics Context Subpackage (`org.dataloader.stats.context`)
7982

8083
| File | Status | Notes |
8184
|------|--------|-------|
82-
| `IncrementBatchLoadCountByStatisticsContext.java` | ❌ Needs annotation | Context class |
83-
| `IncrementBatchLoadExceptionCountStatisticsContext.java` | ❌ Needs annotation | Context class |
84-
| `IncrementCacheHitCountStatisticsContext.java` | ❌ Needs annotation | Context class |
85-
| `IncrementLoadCountStatisticsContext.java` | ❌ Needs annotation | Context class |
86-
| `IncrementLoadErrorCountStatisticsContext.java` | ❌ Needs annotation | Context class |
85+
| `IncrementBatchLoadCountByStatisticsContext.java` | ✅ Done | Added `@NullMarked`, nullable callContext |
86+
| `IncrementBatchLoadExceptionCountStatisticsContext.java` | ✅ Done | Added `@NullMarked`, nullable callContexts |
87+
| `IncrementCacheHitCountStatisticsContext.java` | ✅ Done | Added `@NullMarked`, nullable callContext |
88+
| `IncrementLoadCountStatisticsContext.java` | ✅ Done | Added `@NullMarked`, nullable callContext |
89+
| `IncrementLoadErrorCountStatisticsContext.java` | ✅ Done | Added `@NullMarked`, nullable callContext |
8790

8891
### Phase 4: Instrumentation Package (`org.dataloader.instrumentation`)
8992

9093
| File | Status | Notes |
9194
|------|--------|-------|
92-
| `DataLoaderInstrumentation.java` | ❌ Needs annotation | Methods return `@Nullable DataLoaderInstrumentationContext` |
93-
| `DataLoaderInstrumentationContext.java` | ❌ Needs annotation | Interface with nullable generics |
94-
| `DataLoaderInstrumentationHelper.java` | ❌ Needs annotation | Helper with NOOP implementations |
95-
| `SimpleDataLoaderInstrumentationContext.java` | ❌ Needs annotation | Simple implementation |
96-
| `ChainedDataLoaderInstrumentation.java` | ❌ Needs annotation | Chains multiple instrumentations |
95+
| `DataLoaderInstrumentation.java` | ✅ Done | Added `@NullMarked`, nullable returns and loadContext param |
96+
| `DataLoaderInstrumentationContext.java` | ✅ Done | Added `@NullMarked`, nullable `onCompleted` parameters |
97+
| `DataLoaderInstrumentationHelper.java` | ✅ Done | Added `@NullMarked`, nullable parameters |
98+
| `SimpleDataLoaderInstrumentationContext.java` | ✅ Done | Added `@NullMarked`, nullable fields and callbacks |
99+
| `ChainedDataLoaderInstrumentation.java` | ✅ Done | Added `@NullMarked`, handle nullable contexts |
97100

98101
### Phase 5: Scheduler Package (`org.dataloader.scheduler`)
99102

100103
| File | Status | Notes |
101104
|------|--------|-------|
102-
| `BatchLoaderScheduler.java` | ❌ Needs annotation | Interface; `environment` parameter documented as possibly null |
105+
| `BatchLoaderScheduler.java` | ✅ Done | Added `@NullMarked` |
103106

104107
### Phase 6: Registries Package (`org.dataloader.registries`)
105108

106109
| File | Status | Notes |
107110
|------|--------|-------|
108-
| `DispatchPredicate.java` | ❌ Needs annotation | Functional interface |
111+
| `DispatchPredicate.java` | ✅ Done | Added `@NullMarked` |
109112

110113
### Phase 7: Reactive Package (`org.dataloader.reactive`)
111114

112115
| File | Status | Notes |
113116
|------|--------|-------|
114-
| `ReactiveSupport.java` | ❌ Needs annotation | Factory methods for subscribers |
115-
| `AbstractBatchSubscriber.java` | ❌ Needs annotation | Base subscriber implementation |
116-
| `BatchSubscriberImpl.java` | ❌ Needs annotation | Subscriber implementation |
117-
| `MappedBatchSubscriberImpl.java` | ❌ Needs annotation | Subscriber implementation |
117+
| `ReactiveSupport.java` | ✅ Done | Added `@NullMarked`, nullable callContexts |
118+
| `AbstractBatchSubscriber.java` | ✅ Done | Added `@NullMarked`, nullable callContexts |
119+
| `BatchSubscriberImpl.java` | ✅ Done | Added `@NullMarked` |
120+
| `MappedBatchSubscriberImpl.java` | ✅ Done | Added `@NullMarked`, handle nullable futures |
118121

119122
### Phase 8: Annotations Package (`org.dataloader.annotations`)
120123

121124
| File | Status | Notes |
122125
|------|--------|-------|
123-
| `ExperimentalApi.java` | ❌ Consider | Annotation definition |
124-
| `GuardedBy.java` | ❌ Consider | Annotation definition |
125-
| `Internal.java` | ❌ Consider | Annotation definition |
126-
| `PublicApi.java` | ❌ Consider | Annotation definition |
127-
| `PublicSpi.java` | ❌ Consider | Annotation definition |
128-
| `VisibleForTesting.java` | ❌ Consider | Annotation definition |
126+
| `ExperimentalApi.java` | ⏭️ Skipped | Annotation definition doesn't need null annotations |
127+
| `GuardedBy.java` | ⏭️ Skipped | Annotation definition doesn't need null annotations |
128+
| `Internal.java` | ⏭️ Skipped | Annotation definition doesn't need null annotations |
129+
| `PublicApi.java` | ⏭️ Skipped | Annotation definition doesn't need null annotations |
130+
| `PublicSpi.java` | ⏭️ Skipped | Annotation definition doesn't need null annotations |
131+
| `VisibleForTesting.java` | ⏭️ Skipped | Annotation definition doesn't need null annotations |
129132

130133
> **Note**: Annotation definitions typically don't need `@NullMarked` unless they have methods that return potentially null values.
131134

src/main/java/org/dataloader/DataLoaderOptions.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright (c) 2016 The original author or authors
3+
*
4+
* All rights reserved. This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License v1.0
6+
* and Apache License v2.0 which accompanies this distribution.
7+
*
8+
* The Eclipse Public License is available at
9+
* http://www.eclipse.org/legal/epl-v10.html
10+
*
11+
* The Apache License v2.0 is available at
12+
* http://www.opensource.org/licenses/apache2.0.php
13+
*
14+
* You may elect to redistribute this code under either of these licenses.
15+
*/
16+
117
package org.dataloader;
218

319
import org.dataloader.annotations.PublicApi;

src/main/java/org/dataloader/instrumentation/DataLoaderInstrumentationHelper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public static <U> DataLoaderInstrumentationContext<U> whenDispatched(Runnable co
5858
* @param <U> the generic type
5959
* @return an instrumentation context
6060
*/
61+
@SuppressWarnings("NullAway") // NullAway has issues with generic type inference for BiConsumer with nullable type arguments
6162
public static <U> DataLoaderInstrumentationContext<U> whenCompleted(BiConsumer<@Nullable U, @Nullable Throwable> codeToRun) {
6263
return new SimpleDataLoaderInstrumentationContext<>(null, codeToRun);
6364
}

src/main/java/org/dataloader/reactive/AbstractBatchSubscriber.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void onComplete() {
6969
}
7070

7171
@Override
72-
@SuppressWarnings("NullAway") // NullAway doesn't correctly infer List<@Nullable Object> in generic constructor
72+
@SuppressWarnings("NullAway") // NullAway has issues with generic type inference for List<@Nullable Object>
7373
public void onError(Throwable throwable) {
7474
assertState(!onCompleteCalled, () -> "onComplete has already been called; onError may not be invoked.");
7575
onErrorCalled = true;

src/main/java/org/dataloader/scheduler/BatchLoaderScheduler.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.dataloader.MappedBatchPublisher;
99
import org.dataloader.BatchPublisher;
1010
import org.jspecify.annotations.NullMarked;
11+
import org.jspecify.annotations.Nullable;
1112

1213
import java.util.List;
1314
import java.util.Map;
@@ -59,36 +60,39 @@ interface ScheduledBatchPublisherCall {
5960
* @param scheduledCall the callback that needs to be invoked to allow the {@link BatchLoader} to proceed.
6061
* @param keys this is the list of keys that will be passed to the {@link BatchLoader}.
6162
* This is provided only for informative reasons, and you can't change the keys that are used
62-
* @param environment this is the {@link BatchLoaderEnvironment} in place
63+
* @param environment this is the {@link BatchLoaderEnvironment} in place,
64+
* which can be null if it's a simple {@link BatchLoader} call
6365
* @param <K> the key type
6466
* @param <V> the value type
6567
*
6668
* @return a promise to the values that come from the {@link BatchLoader}
6769
*/
68-
<K, V> CompletionStage<List<V>> scheduleBatchLoader(ScheduledBatchLoaderCall<V> scheduledCall, List<K> keys, BatchLoaderEnvironment environment);
70+
<K, V> CompletionStage<List<V>> scheduleBatchLoader(ScheduledBatchLoaderCall<V> scheduledCall, List<K> keys, @Nullable BatchLoaderEnvironment environment);
6971

7072
/**
7173
* This is called to schedule a {@link MappedBatchLoader} call.
7274
*
7375
* @param scheduledCall the callback that needs to be invoked to allow the {@link MappedBatchLoader} to proceed.
7476
* @param keys this is the list of keys that will be passed to the {@link MappedBatchLoader}.
7577
* This is provided only for informative reasons and, you can't change the keys that are used
76-
* @param environment this is the {@link BatchLoaderEnvironment} in place
78+
* @param environment this is the {@link BatchLoaderEnvironment} in place,
79+
* which can be null if it's a simple {@link MappedBatchLoader} call
7780
* @param <K> the key type
7881
* @param <V> the value type
7982
*
8083
* @return a promise to the values that come from the {@link BatchLoader}
8184
*/
82-
<K, V> CompletionStage<Map<K, V>> scheduleMappedBatchLoader(ScheduledMappedBatchLoaderCall<K, V> scheduledCall, List<K> keys, BatchLoaderEnvironment environment);
85+
<K, V> CompletionStage<Map<K, V>> scheduleMappedBatchLoader(ScheduledMappedBatchLoaderCall<K, V> scheduledCall, List<K> keys, @Nullable BatchLoaderEnvironment environment);
8386

8487
/**
8588
* This is called to schedule a {@link BatchPublisher} call.
8689
*
8790
* @param scheduledCall the callback that needs to be invoked to allow the {@link BatchPublisher} to proceed.
8891
* @param keys this is the list of keys that will be passed to the {@link BatchPublisher}.
8992
* This is provided only for informative reasons and, you can't change the keys that are used
90-
* @param environment this is the {@link BatchLoaderEnvironment} in place
93+
* @param environment this is the {@link BatchLoaderEnvironment} in place,
94+
* which can be null if it's a simple {@link BatchPublisher} call
9195
* @param <K> the key type
9296
*/
93-
<K> void scheduleBatchPublisher(ScheduledBatchPublisherCall scheduledCall, List<K> keys, BatchLoaderEnvironment environment);
97+
<K> void scheduleBatchPublisher(ScheduledBatchPublisherCall scheduledCall, List<K> keys, @Nullable BatchLoaderEnvironment environment);
9498
}

0 commit comments

Comments
 (0)