mirror of https://github.com/apache/activemq.git
fix to avoid NPE
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@515746 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2a3fddbdea
commit
10185cadd7
|
@ -11,42 +11,41 @@
|
|||
* 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.activemq.store.kahadaptor;
|
||||
|
||||
import java.util.Iterator;
|
||||
import org.apache.activemq.command.MessageId;
|
||||
import org.apache.activemq.kaha.ListContainer;
|
||||
import org.apache.activemq.kaha.StoreEntry;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* Holds information for the subscriber
|
||||
*
|
||||
* @version $Revision: 1.10 $
|
||||
*/
|
||||
public class TopicSubContainer{
|
||||
|
||||
public class TopicSubContainer {
|
||||
private ListContainer listContainer;
|
||||
private StoreEntry batchEntry;
|
||||
|
||||
public TopicSubContainer(ListContainer container){
|
||||
public TopicSubContainer(ListContainer container) {
|
||||
this.listContainer = container;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the batchEntry
|
||||
*/
|
||||
public StoreEntry getBatchEntry(){
|
||||
public StoreEntry getBatchEntry() {
|
||||
return this.batchEntry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param batchEntry the batchEntry to set
|
||||
*/
|
||||
public void setBatchEntry(StoreEntry batchEntry){
|
||||
this.batchEntry=batchEntry;
|
||||
public void setBatchEntry(StoreEntry batchEntry) {
|
||||
this.batchEntry = batchEntry;
|
||||
}
|
||||
|
||||
|
||||
public void reset() {
|
||||
batchEntry = null;
|
||||
}
|
||||
|
@ -59,15 +58,15 @@ import org.apache.activemq.kaha.StoreEntry;
|
|||
return listContainer.placeLast(ref);
|
||||
}
|
||||
|
||||
public ConsumerMessageRef remove(MessageId id){
|
||||
ConsumerMessageRef result=null;
|
||||
if(!listContainer.isEmpty()){
|
||||
for(StoreEntry entry=listContainer.getFirst();entry!=null;entry=listContainer.getNext(entry)){
|
||||
ConsumerMessageRef ref=(ConsumerMessageRef)listContainer.get(entry);
|
||||
if(ref!=null&&ref.getMessageId().equals(id)){
|
||||
public ConsumerMessageRef remove(MessageId id) {
|
||||
ConsumerMessageRef result = null;
|
||||
if (!listContainer.isEmpty()) {
|
||||
for (StoreEntry entry = listContainer.getFirst(); entry != null; entry = listContainer.getNext(entry)) {
|
||||
ConsumerMessageRef ref = (ConsumerMessageRef) listContainer.get(entry);
|
||||
if (ref != null && ref.getMessageId().equals(id)) {
|
||||
listContainer.remove(entry);
|
||||
result=ref;
|
||||
if(listContainer.isEmpty()||batchEntry.equals(entry)){
|
||||
result = ref;
|
||||
if (listContainer != null && batchEntry != null && (listContainer.isEmpty() || batchEntry.equals(entry))) {
|
||||
reset();
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +76,7 @@ import org.apache.activemq.kaha.StoreEntry;
|
|||
}
|
||||
|
||||
public ConsumerMessageRef get(StoreEntry entry) {
|
||||
return (ConsumerMessageRef)listContainer.get(entry);
|
||||
return (ConsumerMessageRef) listContainer.get(entry);
|
||||
}
|
||||
|
||||
public StoreEntry getEntry() {
|
||||
|
@ -104,5 +103,4 @@ import org.apache.activemq.kaha.StoreEntry;
|
|||
reset();
|
||||
listContainer.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue