diff --git a/pom.xml b/pom.xml
index 99f134ea..eaf29871 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
org.red5
red5-parent
- 1.0.9-M1
+ 1.0.9-M2
4.0.0
red5-server-common
@@ -100,6 +100,9 @@
+
+ maven-jar-plugin
+
org.apache.felix
maven-bundle-plugin
@@ -111,9 +114,6 @@
maven-javadoc-plugin
-
- maven-jar-plugin
-
diff --git a/src/main/java/org/red5/server/net/rtmp/event/Notify.java b/src/main/java/org/red5/server/net/rtmp/event/Notify.java
index a569329e..e202c822 100644
--- a/src/main/java/org/red5/server/net/rtmp/event/Notify.java
+++ b/src/main/java/org/red5/server/net/rtmp/event/Notify.java
@@ -282,16 +282,15 @@ public Notify duplicate() throws IOException, ClassNotFoundException {
ObjectOutputStream oos = new ObjectOutputStream(baos);
writeExternal(oos);
oos.close();
-
byte[] buf = baos.toByteArray();
baos.close();
-
ByteArrayInputStream bais = new ByteArrayInputStream(buf);
ObjectInputStream ois = new ObjectInputStream(bais);
-
result.readExternal(ois);
ois.close();
bais.close();
+ // set the action if it exists
+ result.setAction(getAction());
return result;
}
diff --git a/src/main/java/org/red5/server/stream/AbstractStream.java b/src/main/java/org/red5/server/stream/AbstractStream.java
index 4ec4b548..8c5a9a88 100644
--- a/src/main/java/org/red5/server/stream/AbstractStream.java
+++ b/src/main/java/org/red5/server/stream/AbstractStream.java
@@ -19,6 +19,7 @@
package org.red5.server.stream;
import java.util.concurrent.Semaphore;
+import java.util.concurrent.atomic.AtomicReference;
import org.red5.codec.IStreamCodecInfo;
import org.red5.codec.StreamCodecInfo;
@@ -54,7 +55,7 @@ public abstract class AbstractStream implements IStream {
/**
* Stores the streams metadata
*/
- protected Notify metaData;
+ private AtomicReference metaData = new AtomicReference<>();
/**
* Stream scope
@@ -90,12 +91,28 @@ public IStreamCodecInfo getCodecInfo() {
}
/**
- * Returns the metadata for the associated stream, if it exists.
+ * Returns a copy of the metadata for the associated stream, if it exists.
*
* @return stream meta data
*/
public Notify getMetaData() {
- return metaData;
+ Notify md = metaData.get();
+ if (md != null) {
+ try {
+ return md.duplicate();
+ } catch (Exception e) {
+ }
+ }
+ return md;
+ }
+
+ /**
+ * Set the metadata.
+ *
+ * @param metaData stream meta data
+ */
+ public void setMetaData(Notify metaData) {
+ this.metaData.set(metaData);
}
/**
diff --git a/src/main/java/org/red5/server/stream/ClientBroadcastStream.java b/src/main/java/org/red5/server/stream/ClientBroadcastStream.java
index feede8f9..ec9eba1d 100644
--- a/src/main/java/org/red5/server/stream/ClientBroadcastStream.java
+++ b/src/main/java/org/red5/server/stream/ClientBroadcastStream.java
@@ -318,12 +318,15 @@ public void dispatchEvent(IEvent event) {
return;
} else if (rtmpEvent instanceof Notify) {
Notify notifyEvent = (Notify) rtmpEvent;
- log.debug("Notify action: {}", notifyEvent.getAction());
- if (notifyEvent.getAction() != null && notifyEvent.getAction().equals("onMetaData")) {
+ String action = notifyEvent.getAction();
+ if (log.isDebugEnabled()) {
+ log.debug("Notify action: {}", action);
+ }
+ if ("onMetaData".equals(action)) {
// store the metadata
try {
log.debug("Setting metadata");
- metaData = notifyEvent.duplicate();
+ setMetaData(notifyEvent.duplicate());
} catch (Exception e) {
log.warn("Metadata could not be duplicated for this stream", e);
}