Skip to content
Closed
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
16 changes: 15 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@
<maven-assembly-plugin.version>3.7.1</maven-assembly-plugin.version>
<maven-jar-plugin.version>3.4.2</maven-jar-plugin.version>
<spring-javaformat-maven-plugin.version>0.0.47</spring-javaformat-maven-plugin.version>
<error-prone.version>2.41.0</error-prone.version>
<error-prone.version>2.42.0</error-prone.version>
<nullaway.version>0.12.10</nullaway.version>
</properties>

<build>
Expand Down Expand Up @@ -180,6 +181,14 @@
<compilerArg>--should-stop=ifError=FLOW</compilerArg>
<compilerArg>
-Xplugin:ErrorProne
<!-- Check JSpecify annotations -->
-Xep:NullAway:ERROR
-XepOpt:NullAway:OnlyNullMarked
<!-- FIXME Remove once https://github.com/uber/NullAway/pull/1295 is released -->
-XepOpt:NullAway:CustomContractAnnotations=org.springframework.lang.Contract
-XepOpt:NullAway:SuppressionNameAliases=DataFlowIssue
<!-- https://github.com/uber/NullAway/issues/162 -->
-XepExcludedPaths:.*/src/test/java/.*
</compilerArg>
</compilerArgs>
<annotationProcessorPaths>
Expand All @@ -188,6 +197,11 @@
<artifactId>error_prone_core</artifactId>
<version>${error-prone.version}</version>
</path>
<path>
<groupId>com.uber.nullaway</groupId>
<artifactId>nullaway</artifactId>
<version>${nullaway.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package org.springframework.batch.item;

import org.jspecify.annotations.Nullable;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -34,6 +36,7 @@
* @author Dave Syer
* @author Mahmoud Ben Hassine
* @author Jinwoo Bae
* @author Stefano Cordio
* @since 2.0
*/
public class Chunk<W> implements Iterable<W>, Serializable {
Expand All @@ -44,7 +47,7 @@ public class Chunk<W> implements Iterable<W>, Serializable {

private final List<Exception> errors = new ArrayList<>();

private Object userData;
private @Nullable Object userData;

private boolean end;

Expand All @@ -65,8 +68,7 @@ public Chunk(List<? extends W> items) {
}

@Deprecated(since = "6.0", forRemoval = true)
public Chunk(List<? extends W> items, List<SkipWrapper<W>> skips) {
super();
public Chunk(@Nullable List<? extends W> items, @Nullable List<SkipWrapper<W>> skips) {
if (items != null) {
this.items.addAll(items);
}
Expand Down Expand Up @@ -218,7 +220,7 @@ public void clearSkips() {
}

@Deprecated(since = "6.0", forRemoval = true)
public Object getUserData() {
public @Nullable Object getUserData() {
return userData;
}

Expand Down Expand Up @@ -266,9 +268,9 @@ public int hashCode() {
*/
public class ChunkIterator implements Iterator<W> {

final private Iterator<W> iterator;
private final Iterator<W> iterator;

private W next;
private @Nullable W next;

public ChunkIterator(List<W> items) {
iterator = items.iterator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;

/**
* Object representing a context for an {@link ItemStream}. It is a thin wrapper for a map
Expand Down Expand Up @@ -254,8 +254,7 @@ public double getDouble(String key, double defaultDouble) {
* @return The value represented by the given key or {@code null} if the key is not
* present
*/
@Nullable
public Object get(String key) {
public @Nullable Object get(String key) {
return this.map.get(key);
}

Expand All @@ -269,8 +268,7 @@ public Object get(String key) {
* key is not present
* @since 5.1
*/
@Nullable
public <V> V get(String key, Class<V> type) {
public <V> @Nullable V get(String key, Class<V> type) {
Object value = this.map.get(key);
if (value == null) {
return null;
Expand All @@ -289,8 +287,7 @@ public <V> V get(String key, Class<V> type) {
* if the key is not present
* @since 5.1
*/
@Nullable
public <V> V get(String key, Class<V> type, @Nullable V defaultValue) {
public <V> @Nullable V get(String key, Class<V> type, @Nullable V defaultValue) {
Object value = this.map.get(key);
if (value == null) {
return defaultValue;
Expand Down Expand Up @@ -373,8 +370,7 @@ public boolean containsKey(String key) {
*
* @see java.util.Map#remove(Object)
*/
@Nullable
public Object remove(String key) {
public @Nullable Object remove(String key) {
return this.map.remove(key);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@

package org.springframework.batch.item;

import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;

/**
* Interface for item transformation. Given an item as input, this interface provides an
Expand Down Expand Up @@ -53,7 +52,6 @@ public interface ItemProcessor<I, O> {
* processing of the provided item should not continue.
* @throws Exception thrown if exception occurs during processing.
*/
@Nullable
O process(@NonNull I item) throws Exception;
@Nullable O process(I item) throws Exception;

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package org.springframework.batch.item;

import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;

/**
* Strategy interface for providing the data. <br>
Expand Down Expand Up @@ -57,7 +57,6 @@ public interface ItemReader<T> {
* @throws Exception if an there is a non-specific error.
* @return T the item to be processed or {@code null} if the data source is exhausted
*/
@Nullable
T read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException;
@Nullable T read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@
*/
package org.springframework.batch.item;

import org.jspecify.annotations.Nullable;

/**
* Exception representing any errors encountered while processing a stream.
*
* @author Dave Syer
* @author Lucas Ward
* @author Mahmoud Ben Hassine
* @author Stefano Cordio
*/
public class ItemStreamException extends RuntimeException {

Expand All @@ -33,11 +36,10 @@ public ItemStreamException(String message) {

/**
* Constructs a new instance with a message and nested exception.
* @param msg the exception message.
* @param msg the exception message (can be {@code null}).
* @param nested the cause of the exception.
*
*/
public ItemStreamException(String msg, Throwable nested) {
public ItemStreamException(@Nullable String msg, Throwable nested) {
super(msg, nested);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.springframework.batch.item;

import org.jspecify.annotations.Nullable;
import org.springframework.batch.item.util.ExecutionContextUserSupport;

/**
Expand All @@ -23,6 +24,7 @@
* @author Dave Syer
* @author Dean de Bree
* @author Mahmoud Ben Hassine
* @author Stefano Cordio
*
*/
public abstract class ItemStreamSupport implements ItemStream {
Expand All @@ -43,7 +45,7 @@ public void setName(String name) {
* Get the name of the component
* @return the name of the component
*/
public String getName() {
public @Nullable String getName() {
return executionContextUserSupport.getName();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package org.springframework.batch.item;

import org.springframework.lang.NonNull;

/**
* <p>
* Basic interface for generic output operations. Class implementing this interface will
Expand Down Expand Up @@ -48,6 +46,6 @@ public interface ItemWriter<T> {
* @throws Exception if there are errors. The framework will catch the exception and
* convert or rethrow it as appropriate.
*/
void write(@NonNull Chunk<? extends T> chunk) throws Exception;
void write(Chunk<? extends T> chunk) throws Exception;

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
package org.springframework.batch.item;

import org.jspecify.annotations.Nullable;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.convert.converter.Converter;
import org.springframework.util.Assert;
Expand All @@ -22,21 +23,20 @@
*
* @author David Turanski
* @author Mahmoud Ben Hassine
* @author Stefano Cordio
* @since 2.2
*
*/
public abstract class KeyValueItemWriter<K, V> implements ItemWriter<V>, InitializingBean {

protected Converter<V, K> itemKeyMapper;
protected @Nullable Converter<V, K> itemKeyMapper;

protected boolean delete;

@Override
public void write(Chunk<? extends V> items) throws Exception {
if (items == null) {
return;
}
for (V item : items) {
public void write(Chunk<? extends V> chunk) throws Exception {
for (V item : chunk) {
@SuppressWarnings("DataFlowIssue")
K key = itemKeyMapper.convert(item);
writeKeyValue(key, item);
}
Expand All @@ -55,7 +55,7 @@ protected void flush() throws Exception {
* @param key the key
* @param value the item
*/
protected abstract void writeKeyValue(K key, V value);
protected abstract void writeKeyValue(@Nullable K key, V value);

/**
* afterPropertiesSet() hook
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package org.springframework.batch.item;

import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;

/**
* <p>
Expand Down Expand Up @@ -45,7 +45,6 @@ public interface PeekableItemReader<T> extends ItemReader<T> {
* @return the next item or {@code null} if the data source is exhausted
* @throws Exception if there is a problem
*/
@Nullable
T peek() throws Exception, UnexpectedInputException, ParseException;
@Nullable T peek() throws Exception, UnexpectedInputException, ParseException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,22 @@

package org.springframework.batch.item;

import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;

/**
* Wrapper for an item and its exception if it failed processing.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
* @author Stefano Cordio
* @deprecated since 6.0 with no replacement. Scheduled for removal in 7.0.
*/
@Deprecated(since = "6.0", forRemoval = true)
public class SkipWrapper<T> {

final private Throwable exception;
private final @Nullable Throwable exception;

final private T item;
private final @Nullable T item;

/**
* @param item the item being wrapped.
Expand All @@ -39,7 +40,7 @@ public SkipWrapper(T item) {
this(item, null);
}

public SkipWrapper(T item, @Nullable Throwable e) {
public SkipWrapper(@Nullable T item, @Nullable Throwable e) {
this.item = item;
this.exception = e;
}
Expand All @@ -48,16 +49,15 @@ public SkipWrapper(T item, @Nullable Throwable e) {
* Public getter for the exception.
* @return the exception
*/
@Nullable
public Throwable getException() {
public @Nullable Throwable getException() {
return exception;
}

/**
* Public getter for the item.
* @return the item
*/
public T getItem() {
public @Nullable T getItem() {
return item;
}

Expand Down
Loading
Loading