Fix in addContent when switching from MemoryAttribute if it is done when

last buffer added, in order to not close immediately the underlying
file before adding the last buffer.

- Contribution by @fredericBregier
This commit is contained in:
Trustin Lee 2012-05-30 17:28:51 -07:00
parent dba9a6d408
commit e8bc276ddd
2 changed files with 9 additions and 9 deletions

View File

@ -15,20 +15,20 @@
*/
package io.netty.handler.codec.http;
import io.netty.buffer.ChannelBuffer;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import io.netty.buffer.ChannelBuffer;
/**
* Mixed implementation using both in Memory and in File with a limit of size
*/
public class MixedAttribute implements Attribute {
private Attribute attribute;
private long limitSize;
private final long limitSize;
public MixedAttribute(String name, long limitSize) {
this.limitSize = limitSize;
@ -65,7 +65,7 @@ public class MixedAttribute implements Attribute {
.getName());
if (((MemoryAttribute) attribute).getChannelBuffer() != null) {
diskAttribute.addContent(((MemoryAttribute) attribute)
.getChannelBuffer(), last);
.getChannelBuffer(), false);
}
attribute = diskAttribute;
}

View File

@ -15,22 +15,22 @@
*/
package io.netty.handler.codec.http;
import io.netty.buffer.ChannelBuffer;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import io.netty.buffer.ChannelBuffer;
/**
* Mixed implementation using both in Memory and in File with a limit of size
*/
public class MixedFileUpload implements FileUpload {
private FileUpload fileUpload;
private long limitSize;
private final long limitSize;
private long definedSize;
private final long definedSize;
public MixedFileUpload(String name, String filename, String contentType,
String contentTransferEncoding, Charset charset, long size,
@ -58,7 +58,7 @@ public class MixedFileUpload implements FileUpload {
definedSize);
if (((MemoryFileUpload) fileUpload).getChannelBuffer() != null) {
diskFileUpload.addContent(((MemoryFileUpload) fileUpload)
.getChannelBuffer(), last);
.getChannelBuffer(), false);
}
fileUpload = diskFileUpload;
}