Consistent use of @Nullable across the codebase (even for internals)
Beyond just formally declaring the current behavior, this revision actually enforces non-null behavior in selected signatures now, not tolerating null values anymore when not explicitly documented. It also changes some utility methods with historic null-in/null-out tolerance towards enforced non-null return values, making them a proper citizen in non-null assignments. Some issues are left as to-do: in particular a thorough revision of spring-test, and a few tests with unclear failures (ignored as "TODO: NULLABLE") to be sorted out in a follow-up commit. Issue: SPR-15540
This commit is contained in:
@@ -84,6 +84,7 @@ public class JmsTemplateTests {
|
||||
|
||||
private QosSettings qosSettings = new QosSettings(DeliveryMode.PERSISTENT, 9, 10000);
|
||||
|
||||
|
||||
/**
|
||||
* Create the mock objects for testing.
|
||||
*/
|
||||
@@ -150,13 +151,10 @@ public class JmsTemplateTests {
|
||||
given(this.session.createProducer(null)).willReturn(messageProducer);
|
||||
given(messageProducer.getPriority()).willReturn(4);
|
||||
|
||||
template.execute(new ProducerCallback<Void>() {
|
||||
@Override
|
||||
public Void doInJms(Session session, MessageProducer producer) throws JMSException {
|
||||
session.getTransacted();
|
||||
producer.getPriority();
|
||||
return null;
|
||||
}
|
||||
template.execute((ProducerCallback<Void>) (session1, producer) -> {
|
||||
session1.getTransacted();
|
||||
producer.getPriority();
|
||||
return null;
|
||||
});
|
||||
|
||||
verify(messageProducer).close();
|
||||
@@ -175,13 +173,10 @@ public class JmsTemplateTests {
|
||||
given(this.session.createProducer(null)).willReturn(messageProducer);
|
||||
given(messageProducer.getPriority()).willReturn(4);
|
||||
|
||||
template.execute(new ProducerCallback<Void>() {
|
||||
@Override
|
||||
public Void doInJms(Session session, MessageProducer producer) throws JMSException {
|
||||
session.getTransacted();
|
||||
producer.getPriority();
|
||||
return null;
|
||||
}
|
||||
template.execute((ProducerCallback<Void>) (session1, producer) -> {
|
||||
session1.getTransacted();
|
||||
producer.getPriority();
|
||||
return null;
|
||||
});
|
||||
|
||||
verify(messageProducer).setDisableMessageID(true);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -38,10 +38,11 @@ import static org.mockito.BDDMockito.*;
|
||||
*/
|
||||
public class MessagingMessageConverterTests {
|
||||
|
||||
private final MessagingMessageConverter converter = new MessagingMessageConverter();
|
||||
|
||||
@Rule
|
||||
public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
private final MessagingMessageConverter converter = new MessagingMessageConverter();
|
||||
|
||||
@Test
|
||||
public void onlyHandlesMessage() throws JMSException {
|
||||
@@ -60,11 +61,6 @@ public class MessagingMessageConverterTests {
|
||||
verify(session).createObjectMessage(payload);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fromNull() throws JMSException {
|
||||
assertNull(this.converter.fromMessage(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customPayloadConverter() throws JMSException {
|
||||
TextMessage jmsMsg = new StubTextMessage("1224");
|
||||
@@ -74,6 +70,7 @@ public class MessagingMessageConverterTests {
|
||||
assertEquals(1224L, msg.getPayload());
|
||||
}
|
||||
|
||||
|
||||
static class TestMessageConverter extends SimpleMessageConverter {
|
||||
|
||||
private boolean called;
|
||||
@@ -87,7 +84,6 @@ public class MessagingMessageConverterTests {
|
||||
TextMessage textMessage = (TextMessage) message;
|
||||
return Long.parseLong(textMessage.getText());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user