Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ public BufferPart(Segment segment, Buffer buffer) {
* @return this returns true if the associated part is a file
*/
public boolean isFile() {
return getDisposition().isFile();
ContentDisposition disposition = getDisposition();
if (disposition == null) {
return false;
}
return disposition.isFile();
}

/**
Expand All @@ -80,7 +84,11 @@ public boolean isFile() {
* @return this returns the name of the associated part
*/
public String getName() {
return getDisposition().getName();
ContentDisposition disposition = getDisposition();
if (disposition == null) {
return null;
}
return disposition.getName();
}

/**
Expand All @@ -91,7 +99,11 @@ public String getName() {
* @return this returns the file name of the associated part
*/
public String getFileName() {
return getDisposition().getFileName();
ContentDisposition disposition = getDisposition();
if (disposition == null) {
return null;
}
return disposition.getFileName();
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.simpleframework.http.message;

import junit.framework.TestCase;
import org.simpleframework.common.buffer.ArrayAllocator;

public class BufferPartTest extends TestCase {

public void testNoDispositionContextNPE() throws Exception {
BufferPart bufferPart = new BufferPart(new MockSegment(), new ArrayAllocator().allocate());
assertNull(bufferPart.getFileName());
assertNull(bufferPart.getName());
assertFalse(bufferPart.isFile());
}
}