This is an automated email from the ASF dual-hosted git repository.
aaronai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-clients.git
The following commit(s) were added to refs/heads/master by this push:
new 22546fb2 Remove redundant code (#424)
22546fb2 is described below
commit 22546fb281e8b18fd76b5112272d8e5f844ecd95
Author: Aaron Ai <[email protected]>
AuthorDate: Tue Mar 28 13:29:42 2023 +0800
Remove redundant code (#424)
---
.../client/java/message/MessageViewImpl.java | 21 +--------
.../rocketmq/client/java/misc/LinkedElement.java | 37 ---------------
.../rocketmq/client/java/misc/LinkedIterator.java | 55 ----------------------
3 files changed, 1 insertion(+), 112 deletions(-)
diff --git
a/java/client/src/main/java/org/apache/rocketmq/client/java/message/MessageViewImpl.java
b/java/client/src/main/java/org/apache/rocketmq/client/java/message/MessageViewImpl.java
index 33ad88bb..b657f934 100644
---
a/java/client/src/main/java/org/apache/rocketmq/client/java/message/MessageViewImpl.java
+++
b/java/client/src/main/java/org/apache/rocketmq/client/java/message/MessageViewImpl.java
@@ -33,20 +33,17 @@ import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
import java.util.Optional;
import org.apache.rocketmq.client.apis.message.MessageId;
import org.apache.rocketmq.client.apis.message.MessageView;
-import org.apache.rocketmq.client.java.misc.LinkedElement;
-import org.apache.rocketmq.client.java.misc.LinkedIterator;
import org.apache.rocketmq.client.java.misc.Utilities;
import org.apache.rocketmq.client.java.route.Endpoints;
import org.apache.rocketmq.client.java.route.MessageQueueImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class MessageViewImpl implements LinkedElement<MessageViewImpl>,
MessageView {
+public class MessageViewImpl implements MessageView {
private static final Logger log =
LoggerFactory.getLogger(MessageViewImpl.class);
final byte[] body;
@@ -67,7 +64,6 @@ public class MessageViewImpl implements
LinkedElement<MessageViewImpl>, MessageV
private final boolean corrupted;
private final long decodeTimestamp;
private final Long transportDeliveryTimestamp;
- private MessageViewImpl next;
public MessageViewImpl(MessageId messageId, String topic, byte[] body,
String tag, String messageGroup,
Long deliveryTimestamp, Collection<String> keys, Map<String, String>
properties,
@@ -92,7 +88,6 @@ public class MessageViewImpl implements
LinkedElement<MessageViewImpl>, MessageV
this.corrupted = corrupted;
this.decodeTimestamp = System.currentTimeMillis();
this.transportDeliveryTimestamp = transportDeliveryTimestamp;
- this.next = null;
}
/**
@@ -221,20 +216,6 @@ public class MessageViewImpl implements
LinkedElement<MessageViewImpl>, MessageV
return Optional.ofNullable(transportDeliveryTimestamp);
}
- public void setNext(MessageViewImpl messageView) {
- this.next = messageView;
- }
-
- @Override
- public MessageViewImpl getNext() {
- return next;
- }
-
- @Override
- public Iterator<MessageViewImpl> iterator() {
- return new LinkedIterator<>(this);
- }
-
public static MessageViewImpl fromProtobuf(Message message) {
return MessageViewImpl.fromProtobuf(message, null);
}
diff --git
a/java/client/src/main/java/org/apache/rocketmq/client/java/misc/LinkedElement.java
b/java/client/src/main/java/org/apache/rocketmq/client/java/misc/LinkedElement.java
deleted file mode 100644
index 893c89a1..00000000
---
a/java/client/src/main/java/org/apache/rocketmq/client/java/misc/LinkedElement.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.rocketmq.client.java.misc;
-
-import java.util.Iterator;
-
-/**
- * Linked element is a simple class that allows you to link elements together.
- *
- * @param <T> the type of the elements to be linked.
- */
-public interface LinkedElement<T> {
- /**
- * @return the next element in the linked list.
- */
- T getNext();
-
- /**
- * @return the iterator over the linked list.
- */
- Iterator<T> iterator();
-}
\ No newline at end of file
diff --git
a/java/client/src/main/java/org/apache/rocketmq/client/java/misc/LinkedIterator.java
b/java/client/src/main/java/org/apache/rocketmq/client/java/misc/LinkedIterator.java
deleted file mode 100644
index 93b0aaad..00000000
---
a/java/client/src/main/java/org/apache/rocketmq/client/java/misc/LinkedIterator.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.rocketmq.client.java.misc;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-/**
- * Linked iterator is a simple iterator class that allows you to iterate over
a linked list.
- *
- * @param <T> the type of the elements to be iterated over.
- */
-public class LinkedIterator<T extends LinkedElement<T>> implements Iterator<T>
{
- private T cursor;
-
- public LinkedIterator(T cursor) {
- this.cursor = cursor;
- }
-
- /**
- * @see Iterator#hasNext()
- */
- @Override
- public boolean hasNext() {
- return null != cursor;
- }
-
- /**
- * @see Iterator#next()
- */
- @Override
- public T next() {
- if (null == cursor) {
- throw new NoSuchElementException();
- }
- T t = cursor;
- cursor = cursor.getNext();
- return t;
- }
-}