Skip to content

Commit ecb77fe

Browse files
authored
QPID-8676 - [Broker-J] NPE when detaching endpoint (#246)
1 parent f962e7f commit ecb77fe

File tree

3 files changed

+391
-2
lines changed

3 files changed

+391
-2
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.qpid.server.util;
20+
21+
import java.util.ArrayList;
22+
import java.util.Arrays;
23+
import java.util.List;
24+
25+
/**
26+
* Collection utilities
27+
*/
28+
public final class CollectionUtils
29+
{
30+
/** Utility class shouldn't be instantiated directly */
31+
private CollectionUtils()
32+
{
33+
34+
}
35+
36+
/**
37+
* Returns a fixed-size list backed by the specified array. When array is null, returns an empty list
38+
* @param array Array of elements
39+
* @return List of elements
40+
* @param <T> Element type
41+
*/
42+
public static <T> List<T> nullSafeList(final T[] array)
43+
{
44+
if (array == null)
45+
{
46+
return new ArrayList<>();
47+
}
48+
return Arrays.asList(array);
49+
}
50+
}

broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/TxnCoordinatorReceivingLinkEndpoint.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
package org.apache.qpid.server.protocol.v1_0;
2121

22-
import java.util.Arrays;
2322
import java.util.Collections;
2423
import java.util.List;
2524
import java.util.Map;
@@ -50,6 +49,7 @@
5049
import org.apache.qpid.server.protocol.v1_0.type.transport.Error;
5150
import org.apache.qpid.server.txn.LocalTransaction;
5251
import org.apache.qpid.server.txn.ServerTransaction;
52+
import org.apache.qpid.server.util.CollectionUtils;
5353
import org.apache.qpid.server.util.ConnectionScopedRuntimeException;
5454
import org.apache.qpid.server.util.ServerScopedRuntimeException;
5555

@@ -121,7 +121,7 @@ else if (command instanceof Discharge)
121121
{
122122
outcome = new Accepted();
123123
}
124-
else if (Arrays.asList(getSource().getOutcomes()).contains(Rejected.REJECTED_SYMBOL))
124+
else if (CollectionUtils.nullSafeList(getSource().getOutcomes()).contains(Rejected.REJECTED_SYMBOL))
125125
{
126126
final Rejected rejected = new Rejected();
127127
rejected.setError(error);

0 commit comments

Comments
 (0)