Skip to content

Commit

Permalink
QPID-8676 - [Broker-J] NPE when detaching endpoint (#246)
Browse files Browse the repository at this point in the history
  • Loading branch information
dakirily authored Sep 30, 2024
1 parent f962e7f commit ecb77fe
Show file tree
Hide file tree
Showing 3 changed files with 391 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.qpid.server.util;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
* Collection utilities
*/
public final class CollectionUtils
{
/** Utility class shouldn't be instantiated directly */
private CollectionUtils()
{

}

/**
* Returns a fixed-size list backed by the specified array. When array is null, returns an empty list
* @param array Array of elements
* @return List of elements
* @param <T> Element type
*/
public static <T> List<T> nullSafeList(final T[] array)
{
if (array == null)
{
return new ArrayList<>();
}
return Arrays.asList(array);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

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

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -50,6 +49,7 @@
import org.apache.qpid.server.protocol.v1_0.type.transport.Error;
import org.apache.qpid.server.txn.LocalTransaction;
import org.apache.qpid.server.txn.ServerTransaction;
import org.apache.qpid.server.util.CollectionUtils;
import org.apache.qpid.server.util.ConnectionScopedRuntimeException;
import org.apache.qpid.server.util.ServerScopedRuntimeException;

Expand Down Expand Up @@ -121,7 +121,7 @@ else if (command instanceof Discharge)
{
outcome = new Accepted();
}
else if (Arrays.asList(getSource().getOutcomes()).contains(Rejected.REJECTED_SYMBOL))
else if (CollectionUtils.nullSafeList(getSource().getOutcomes()).contains(Rejected.REJECTED_SYMBOL))
{
final Rejected rejected = new Rejected();
rejected.setError(error);
Expand Down
Loading

0 comments on commit ecb77fe

Please sign in to comment.