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:
Juergen Hoeller
2017-06-07 14:17:48 +02:00
parent ffc3f6d87d
commit f813712f5b
1493 changed files with 10670 additions and 9172 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 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.
@@ -16,8 +16,6 @@
package org.springframework.web.socket.messaging;
import static org.junit.Assert.*;
import java.security.Principal;
import java.util.Arrays;
import java.util.HashSet;
@@ -35,6 +33,8 @@ import org.springframework.messaging.simp.user.SimpUser;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.socket.CloseStatus;
import static org.junit.Assert.*;
/**
* Test fixture for
* {@link DefaultSimpUserRegistry}
@@ -46,7 +46,6 @@ public class DefaultSimpUserRegistryTests {
@Test
public void addOneSessionId() {
TestPrincipal user = new TestPrincipal("joe");
Message<byte[]> message = createMessage(SimpMessageType.CONNECT_ACK, "123");
SessionConnectedEvent event = new SessionConnectedEvent(this, message, user);
@@ -64,7 +63,6 @@ public class DefaultSimpUserRegistryTests {
@Test
public void addMultipleSessionIds() {
DefaultSimpUserRegistry registry = new DefaultSimpUserRegistry();
TestPrincipal user = new TestPrincipal("joe");
@@ -92,7 +90,6 @@ public class DefaultSimpUserRegistryTests {
@Test
public void removeSessionIds() {
DefaultSimpUserRegistry registry = new DefaultSimpUserRegistry();
TestPrincipal user = new TestPrincipal("joe");
@@ -112,7 +109,6 @@ public class DefaultSimpUserRegistryTests {
assertNotNull(simpUser);
assertEquals(3, simpUser.getSessions().size());
CloseStatus status = CloseStatus.GOING_AWAY;
message = createMessage(SimpMessageType.DISCONNECT, "456");
SessionDisconnectEvent disconnectEvent = new SessionDisconnectEvent(this, message, "456", status, user);
@@ -128,7 +124,6 @@ public class DefaultSimpUserRegistryTests {
@Test
public void findSubscriptions() throws Exception {
DefaultSimpUserRegistry registry = new DefaultSimpUserRegistry();
TestPrincipal user = new TestPrincipal("joe");
@@ -166,7 +161,6 @@ public class DefaultSimpUserRegistryTests {
@Test
public void nullSessionId() throws Exception {
DefaultSimpUserRegistry registry = new DefaultSimpUserRegistry();
TestPrincipal user = new TestPrincipal("joe");

View File

@@ -23,6 +23,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -66,6 +67,7 @@ import static org.springframework.web.socket.messaging.StompTextMessageBuilder.*
* @author Rossen Stoyanchev
*/
@RunWith(Parameterized.class)
@Ignore // TODO: NULLABLE
public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegrationTests {
private static final long TIMEOUT = 10;