[CXF-8627]AttachmentDataSource should always returns a valid contentType
@@ -25,6 +25,7 @@ import java.io.OutputStream;
import javax.activation.DataSource;
+import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.helpers.IOUtils;
import org.apache.cxf.io.CacheSizeExceededException;
import org.apache.cxf.io.CachedOutputStream;
@@ -32,7 +33,7 @@ import org.apache.cxf.message.Message;
public class AttachmentDataSource implements DataSource {
- private final String ct;
+ private String ct;
private CachedOutputStream cache;
private InputStream ins;
private DelegatingInputStream delegate;
@@ -76,6 +77,9 @@ public class AttachmentDataSource implements DataSource {
}
public String getContentType() {
+ if (StringUtils.isEmpty(ct)) {
+ ct = "application/octet-stream";
+ }
return ct;
}
