Fix some inspector warnings

This commit is contained in:
Trustin Lee 2013-11-04 18:03:32 +09:00
parent 651c7b056a
commit a5f33f4020
3 changed files with 87 additions and 71 deletions

View File

@ -132,7 +132,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
* if the default charset was wrong when decoding or other * if the default charset was wrong when decoding or other
* errors * errors
*/ */
public HttpPostMultipartRequestDecoder(HttpRequest request) throws ErrorDataDecoderException { public HttpPostMultipartRequestDecoder(HttpRequest request) {
this(new DefaultHttpDataFactory(DefaultHttpDataFactory.MINSIZE), request, HttpConstants.DEFAULT_CHARSET); this(new DefaultHttpDataFactory(DefaultHttpDataFactory.MINSIZE), request, HttpConstants.DEFAULT_CHARSET);
} }
@ -148,8 +148,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
* if the default charset was wrong when decoding or other * if the default charset was wrong when decoding or other
* errors * errors
*/ */
public HttpPostMultipartRequestDecoder(HttpDataFactory factory, HttpRequest request) public HttpPostMultipartRequestDecoder(HttpDataFactory factory, HttpRequest request) {
throws ErrorDataDecoderException {
this(factory, request, HttpConstants.DEFAULT_CHARSET); this(factory, request, HttpConstants.DEFAULT_CHARSET);
} }
@ -167,8 +166,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
* if the default charset was wrong when decoding or other * if the default charset was wrong when decoding or other
* errors * errors
*/ */
public HttpPostMultipartRequestDecoder(HttpDataFactory factory, HttpRequest request, Charset charset) public HttpPostMultipartRequestDecoder(HttpDataFactory factory, HttpRequest request, Charset charset) {
throws ErrorDataDecoderException {
if (factory == null) { if (factory == null) {
throw new NullPointerException("factory"); throw new NullPointerException("factory");
} }
@ -196,11 +194,8 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
/** /**
* Set from the request ContentType the multipartDataBoundary. * Set from the request ContentType the multipartDataBoundary.
* @param contentType
* @throws ErrorDataDecoderException
* @throws ErrorDataDecoderException
*/ */
private void setMultipart(String contentType) throws ErrorDataDecoderException { private void setMultipart(String contentType) {
multipartDataBoundary = HttpPostRequestDecoder.getMultipartDataBoundary(contentType); multipartDataBoundary = HttpPostRequestDecoder.getMultipartDataBoundary(contentType);
currentStatus = MultiPartStatus.HEADERDELIMITER; currentStatus = MultiPartStatus.HEADERDELIMITER;
} }
@ -217,6 +212,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
* *
* @return True if this request is a Multipart request * @return True if this request is a Multipart request
*/ */
@Override
public boolean isMultipart() { public boolean isMultipart() {
checkDestroyed(); checkDestroyed();
return true; return true;
@ -227,6 +223,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
* Setting this lower gives lower memory usage but with the overhead of more memory copies. * Setting this lower gives lower memory usage but with the overhead of more memory copies.
* Use {@code 0} to disable it. * Use {@code 0} to disable it.
*/ */
@Override
public void setDiscardThreshold(int discardThreshold) { public void setDiscardThreshold(int discardThreshold) {
if (discardThreshold < 0) { if (discardThreshold < 0) {
throw new IllegalArgumentException("discardThreshold must be >= 0"); throw new IllegalArgumentException("discardThreshold must be >= 0");
@ -237,6 +234,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
/** /**
* Return the threshold in bytes after which read data in the buffer should be discarded. * Return the threshold in bytes after which read data in the buffer should be discarded.
*/ */
@Override
public int getDiscardThreshold() { public int getDiscardThreshold() {
return discardThreshold; return discardThreshold;
} }
@ -251,7 +249,8 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
* @throws NotEnoughDataDecoderException * @throws NotEnoughDataDecoderException
* Need more chunks * Need more chunks
*/ */
public List<InterfaceHttpData> getBodyHttpDatas() throws NotEnoughDataDecoderException { @Override
public List<InterfaceHttpData> getBodyHttpDatas() {
checkDestroyed(); checkDestroyed();
if (!isLastChunk) { if (!isLastChunk) {
@ -271,7 +270,8 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
* @throws NotEnoughDataDecoderException * @throws NotEnoughDataDecoderException
* need more chunks * need more chunks
*/ */
public List<InterfaceHttpData> getBodyHttpDatas(String name) throws NotEnoughDataDecoderException { @Override
public List<InterfaceHttpData> getBodyHttpDatas(String name) {
checkDestroyed(); checkDestroyed();
if (!isLastChunk) { if (!isLastChunk) {
@ -292,7 +292,8 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
* @throws NotEnoughDataDecoderException * @throws NotEnoughDataDecoderException
* need more chunks * need more chunks
*/ */
public InterfaceHttpData getBodyHttpData(String name) throws NotEnoughDataDecoderException { @Override
public InterfaceHttpData getBodyHttpData(String name) {
checkDestroyed(); checkDestroyed();
if (!isLastChunk) { if (!isLastChunk) {
@ -314,7 +315,8 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
* if there is a problem with the charset decoding or other * if there is a problem with the charset decoding or other
* errors * errors
*/ */
public HttpPostMultipartRequestDecoder offer(HttpContent content) throws ErrorDataDecoderException { @Override
public HttpPostMultipartRequestDecoder offer(HttpContent content) {
checkDestroyed(); checkDestroyed();
// Maybe we should better not copy here for performance reasons but this will need // Maybe we should better not copy here for performance reasons but this will need
@ -346,7 +348,8 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
* @throws EndOfDataDecoderException * @throws EndOfDataDecoderException
* No more data will be available * No more data will be available
*/ */
public boolean hasNext() throws EndOfDataDecoderException { @Override
public boolean hasNext() {
checkDestroyed(); checkDestroyed();
if (currentStatus == MultiPartStatus.EPILOGUE) { if (currentStatus == MultiPartStatus.EPILOGUE) {
@ -370,7 +373,8 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
* @throws EndOfDataDecoderException * @throws EndOfDataDecoderException
* No more data will be available * No more data will be available
*/ */
public InterfaceHttpData next() throws EndOfDataDecoderException { @Override
public InterfaceHttpData next() {
checkDestroyed(); checkDestroyed();
if (hasNext()) { if (hasNext()) {
@ -386,7 +390,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
* if there is a problem with the charset decoding or other * if there is a problem with the charset decoding or other
* errors * errors
*/ */
private void parseBody() throws ErrorDataDecoderException { private void parseBody() {
if (currentStatus == MultiPartStatus.PREEPILOGUE || currentStatus == MultiPartStatus.EPILOGUE) { if (currentStatus == MultiPartStatus.PREEPILOGUE || currentStatus == MultiPartStatus.EPILOGUE) {
if (isLastChunk) { if (isLastChunk) {
currentStatus = MultiPartStatus.EPILOGUE; currentStatus = MultiPartStatus.EPILOGUE;
@ -419,7 +423,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
* if there is a problem with the charset decoding or other * if there is a problem with the charset decoding or other
* errors * errors
*/ */
private void parseBodyMultipart() throws ErrorDataDecoderException { private void parseBodyMultipart() {
if (undecodedChunk == null || undecodedChunk.readableBytes() == 0) { if (undecodedChunk == null || undecodedChunk.readableBytes() == 0) {
// nothing to decode // nothing to decode
return; return;
@ -450,7 +454,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
* @throws ErrorDataDecoderException * @throws ErrorDataDecoderException
* if an error occurs * if an error occurs
*/ */
private InterfaceHttpData decodeMultipart(MultiPartStatus state) throws ErrorDataDecoderException { private InterfaceHttpData decodeMultipart(MultiPartStatus state) {
switch (state) { switch (state) {
case NOTSTARTED: case NOTSTARTED:
throw new ErrorDataDecoderException("Should not be called with the current getStatus"); throw new ErrorDataDecoderException("Should not be called with the current getStatus");
@ -545,7 +549,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
* *
* @throws NotEnoughDataDecoderException * @throws NotEnoughDataDecoderException
*/ */
void skipControlCharacters() throws NotEnoughDataDecoderException { void skipControlCharacters() {
SeekAheadOptimize sao; SeekAheadOptimize sao;
try { try {
sao = new SeekAheadOptimize(undecodedChunk); sao = new SeekAheadOptimize(undecodedChunk);
@ -591,7 +595,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
* @throws ErrorDataDecoderException * @throws ErrorDataDecoderException
*/ */
private InterfaceHttpData findMultipartDelimiter(String delimiter, MultiPartStatus dispositionStatus, private InterfaceHttpData findMultipartDelimiter(String delimiter, MultiPartStatus dispositionStatus,
MultiPartStatus closeDelimiterStatus) throws ErrorDataDecoderException { MultiPartStatus closeDelimiterStatus) {
// --AaB03x or --AaB03x-- // --AaB03x or --AaB03x--
int readerIndex = undecodedChunk.readerIndex(); int readerIndex = undecodedChunk.readerIndex();
try { try {
@ -633,7 +637,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
* @return the next InterfaceHttpData if any * @return the next InterfaceHttpData if any
* @throws ErrorDataDecoderException * @throws ErrorDataDecoderException
*/ */
private InterfaceHttpData findMultipartDisposition() throws ErrorDataDecoderException { private InterfaceHttpData findMultipartDisposition() {
int readerIndex = undecodedChunk.readerIndex(); int readerIndex = undecodedChunk.readerIndex();
if (currentStatus == MultiPartStatus.DISPOSITION) { if (currentStatus == MultiPartStatus.DISPOSITION) {
currentFieldAttributes = new TreeMap<String, Attribute>(CaseIgnoringComparator.INSTANCE); currentFieldAttributes = new TreeMap<String, Attribute>(CaseIgnoringComparator.INSTANCE);
@ -783,7 +787,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
* @return the InterfaceHttpData if any * @return the InterfaceHttpData if any
* @throws ErrorDataDecoderException * @throws ErrorDataDecoderException
*/ */
protected InterfaceHttpData getFileUpload(String delimiter) throws ErrorDataDecoderException { protected InterfaceHttpData getFileUpload(String delimiter) {
// eventually restart from existing FileUpload // eventually restart from existing FileUpload
// Now get value according to Content-Type and Charset // Now get value according to Content-Type and Charset
Attribute encoding = currentFieldAttributes.get(HttpHeaders.Names.CONTENT_TRANSFER_ENCODING); Attribute encoding = currentFieldAttributes.get(HttpHeaders.Names.CONTENT_TRANSFER_ENCODING);
@ -878,6 +882,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
* Destroy the {@link HttpPostMultipartRequestDecoder} and release all it resources. After this method * Destroy the {@link HttpPostMultipartRequestDecoder} and release all it resources. After this method
* was called it is not possible to operate on it anymore. * was called it is not possible to operate on it anymore.
*/ */
@Override
public void destroy() { public void destroy() {
checkDestroyed(); checkDestroyed();
cleanFiles(); cleanFiles();
@ -897,6 +902,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
/** /**
* Clean all HttpDatas (on Disk) for the current request. * Clean all HttpDatas (on Disk) for the current request.
*/ */
@Override
public void cleanFiles() { public void cleanFiles() {
checkDestroyed(); checkDestroyed();
@ -906,6 +912,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
/** /**
* Remove the given FileUpload from the list of FileUploads to clean * Remove the given FileUpload from the list of FileUploads to clean
*/ */
@Override
public void removeHttpDataFromClean(InterfaceHttpData data) { public void removeHttpDataFromClean(InterfaceHttpData data) {
checkDestroyed(); checkDestroyed();
@ -932,7 +939,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
* Need more chunks and reset the readerInder to the previous * Need more chunks and reset the readerInder to the previous
* value * value
*/ */
private String readLineStandard() throws NotEnoughDataDecoderException { private String readLineStandard() {
int readerIndex = undecodedChunk.readerIndex(); int readerIndex = undecodedChunk.readerIndex();
try { try {
ByteBuf line = buffer(64); ByteBuf line = buffer(64);
@ -966,7 +973,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
* Need more chunks and reset the readerInder to the previous * Need more chunks and reset the readerInder to the previous
* value * value
*/ */
private String readLine() throws NotEnoughDataDecoderException { private String readLine() {
SeekAheadOptimize sao; SeekAheadOptimize sao;
try { try {
sao = new SeekAheadOptimize(undecodedChunk); sao = new SeekAheadOptimize(undecodedChunk);
@ -1019,7 +1026,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
* Need more chunks and reset the readerInder to the previous * Need more chunks and reset the readerInder to the previous
* value * value
*/ */
private String readDelimiterStandard(String delimiter) throws NotEnoughDataDecoderException { private String readDelimiterStandard(String delimiter) {
int readerIndex = undecodedChunk.readerIndex(); int readerIndex = undecodedChunk.readerIndex();
try { try {
StringBuilder sb = new StringBuilder(64); StringBuilder sb = new StringBuilder(64);
@ -1113,7 +1120,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
* Need more chunks and reset the readerInder to the previous * Need more chunks and reset the readerInder to the previous
* value * value
*/ */
private String readDelimiter(String delimiter) throws NotEnoughDataDecoderException { private String readDelimiter(String delimiter) {
SeekAheadOptimize sao; SeekAheadOptimize sao;
try { try {
sao = new SeekAheadOptimize(undecodedChunk); sao = new SeekAheadOptimize(undecodedChunk);
@ -1225,8 +1232,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
* @throws ErrorDataDecoderException * @throws ErrorDataDecoderException
* write IO error occurs with the FileUpload * write IO error occurs with the FileUpload
*/ */
private void readFileUploadByteMultipartStandard(String delimiter) throws NotEnoughDataDecoderException, private void readFileUploadByteMultipartStandard(String delimiter) {
ErrorDataDecoderException {
int readerIndex = undecodedChunk.readerIndex(); int readerIndex = undecodedChunk.readerIndex();
// found the decoder limit // found the decoder limit
boolean newLine = true; boolean newLine = true;
@ -1333,8 +1339,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
* @throws ErrorDataDecoderException * @throws ErrorDataDecoderException
* write IO error occurs with the FileUpload * write IO error occurs with the FileUpload
*/ */
private void readFileUploadByteMultipart(String delimiter) throws NotEnoughDataDecoderException, private void readFileUploadByteMultipart(String delimiter) {
ErrorDataDecoderException {
SeekAheadOptimize sao; SeekAheadOptimize sao;
try { try {
sao = new SeekAheadOptimize(undecodedChunk); sao = new SeekAheadOptimize(undecodedChunk);
@ -1448,8 +1453,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
* Need more chunks * Need more chunks
* @throws ErrorDataDecoderException * @throws ErrorDataDecoderException
*/ */
private void loadFieldMultipartStandard(String delimiter) throws NotEnoughDataDecoderException, private void loadFieldMultipartStandard(String delimiter) {
ErrorDataDecoderException {
int readerIndex = undecodedChunk.readerIndex(); int readerIndex = undecodedChunk.readerIndex();
try { try {
// found the decoder limit // found the decoder limit
@ -1544,7 +1548,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
* Need more chunks * Need more chunks
* @throws ErrorDataDecoderException * @throws ErrorDataDecoderException
*/ */
private void loadFieldMultipart(String delimiter) throws NotEnoughDataDecoderException, ErrorDataDecoderException { private void loadFieldMultipart(String delimiter) {
SeekAheadOptimize sao; SeekAheadOptimize sao;
try { try {
sao = new SeekAheadOptimize(undecodedChunk); sao = new SeekAheadOptimize(undecodedChunk);

View File

@ -45,7 +45,7 @@ public class HttpPostRequestDecoder implements InterfaceHttpPostRequestDecoder {
* if the default charset was wrong when decoding or other * if the default charset was wrong when decoding or other
* errors * errors
*/ */
public HttpPostRequestDecoder(HttpRequest request) throws ErrorDataDecoderException { public HttpPostRequestDecoder(HttpRequest request) {
this(new DefaultHttpDataFactory(DefaultHttpDataFactory.MINSIZE), request, HttpConstants.DEFAULT_CHARSET); this(new DefaultHttpDataFactory(DefaultHttpDataFactory.MINSIZE), request, HttpConstants.DEFAULT_CHARSET);
} }
@ -61,7 +61,7 @@ public class HttpPostRequestDecoder implements InterfaceHttpPostRequestDecoder {
* if the default charset was wrong when decoding or other * if the default charset was wrong when decoding or other
* errors * errors
*/ */
public HttpPostRequestDecoder(HttpDataFactory factory, HttpRequest request) throws ErrorDataDecoderException { public HttpPostRequestDecoder(HttpDataFactory factory, HttpRequest request) {
this(factory, request, HttpConstants.DEFAULT_CHARSET); this(factory, request, HttpConstants.DEFAULT_CHARSET);
} }
@ -79,8 +79,7 @@ public class HttpPostRequestDecoder implements InterfaceHttpPostRequestDecoder {
* if the default charset was wrong when decoding or other * if the default charset was wrong when decoding or other
* errors * errors
*/ */
public HttpPostRequestDecoder(HttpDataFactory factory, HttpRequest request, Charset charset) public HttpPostRequestDecoder(HttpDataFactory factory, HttpRequest request, Charset charset) {
throws ErrorDataDecoderException {
if (factory == null) { if (factory == null) {
throw new NullPointerException("factory"); throw new NullPointerException("factory");
} }
@ -135,11 +134,9 @@ public class HttpPostRequestDecoder implements InterfaceHttpPostRequestDecoder {
/** /**
* Check if the given request is a multipart request * Check if the given request is a multipart request
* @param request
* @return True if the request is a Multipart request * @return True if the request is a Multipart request
* @throws ErrorDataDecoderException
*/ */
public static boolean isMultipart(HttpRequest request) throws ErrorDataDecoderException { public static boolean isMultipart(HttpRequest request) {
if (request.headers().contains(HttpHeaders.Names.CONTENT_TYPE)) { if (request.headers().contains(HttpHeaders.Names.CONTENT_TYPE)) {
return getMultipartDataBoundary(request.headers().get(HttpHeaders.Names.CONTENT_TYPE)) != null; return getMultipartDataBoundary(request.headers().get(HttpHeaders.Names.CONTENT_TYPE)) != null;
} else { } else {
@ -151,8 +148,7 @@ public class HttpPostRequestDecoder implements InterfaceHttpPostRequestDecoder {
* Check from the request ContentType if this request is a Multipart request. * Check from the request ContentType if this request is a Multipart request.
* @return the multipartDataBoundary if it exists, else null * @return the multipartDataBoundary if it exists, else null
*/ */
protected static String getMultipartDataBoundary(String contentType) protected static String getMultipartDataBoundary(String contentType) {
throws ErrorDataDecoderException {
// Check if Post using "multipart/form-data; boundary=--89421926422648" // Check if Post using "multipart/form-data; boundary=--89421926422648"
String[] headerContentType = splitHeaderContentType(contentType); String[] headerContentType = splitHeaderContentType(contentType);
if (headerContentType[0].toLowerCase().startsWith( if (headerContentType[0].toLowerCase().startsWith(
@ -169,50 +165,62 @@ public class HttpPostRequestDecoder implements InterfaceHttpPostRequestDecoder {
} }
} }
@Override
public boolean isMultipart() { public boolean isMultipart() {
return decoder.isMultipart(); return decoder.isMultipart();
} }
@Override
public void setDiscardThreshold(int discardThreshold) { public void setDiscardThreshold(int discardThreshold) {
decoder.setDiscardThreshold(discardThreshold); decoder.setDiscardThreshold(discardThreshold);
} }
@Override
public int getDiscardThreshold() { public int getDiscardThreshold() {
return decoder.getDiscardThreshold(); return decoder.getDiscardThreshold();
} }
public List<InterfaceHttpData> getBodyHttpDatas() throws NotEnoughDataDecoderException { @Override
public List<InterfaceHttpData> getBodyHttpDatas() {
return decoder.getBodyHttpDatas(); return decoder.getBodyHttpDatas();
} }
public List<InterfaceHttpData> getBodyHttpDatas(String name) throws NotEnoughDataDecoderException { @Override
public List<InterfaceHttpData> getBodyHttpDatas(String name) {
return decoder.getBodyHttpDatas(name); return decoder.getBodyHttpDatas(name);
} }
public InterfaceHttpData getBodyHttpData(String name) throws NotEnoughDataDecoderException { @Override
public InterfaceHttpData getBodyHttpData(String name) {
return decoder.getBodyHttpData(name); return decoder.getBodyHttpData(name);
} }
public InterfaceHttpPostRequestDecoder offer(HttpContent content) throws ErrorDataDecoderException { @Override
public InterfaceHttpPostRequestDecoder offer(HttpContent content) {
return decoder.offer(content); return decoder.offer(content);
} }
public boolean hasNext() throws EndOfDataDecoderException { @Override
public boolean hasNext() {
return decoder.hasNext(); return decoder.hasNext();
} }
public InterfaceHttpData next() throws EndOfDataDecoderException { @Override
public InterfaceHttpData next() {
return decoder.next(); return decoder.next();
} }
@Override
public void destroy() { public void destroy() {
decoder.destroy(); decoder.destroy();
} }
@Override
public void cleanFiles() { public void cleanFiles() {
decoder.cleanFiles(); decoder.cleanFiles();
} }
@Override
public void removeHttpDataFromClean(InterfaceHttpData data) { public void removeHttpDataFromClean(InterfaceHttpData data) {
decoder.removeHttpDataFromClean(data); decoder.removeHttpDataFromClean(data);
} }

View File

@ -110,8 +110,7 @@ public class HttpPostStandardRequestDecoder implements InterfaceHttpPostRequestD
* if the default charset was wrong when decoding or other * if the default charset was wrong when decoding or other
* errors * errors
*/ */
public HttpPostStandardRequestDecoder(HttpRequest request) public HttpPostStandardRequestDecoder(HttpRequest request) {
throws ErrorDataDecoderException {
this(new DefaultHttpDataFactory(DefaultHttpDataFactory.MINSIZE), request, HttpConstants.DEFAULT_CHARSET); this(new DefaultHttpDataFactory(DefaultHttpDataFactory.MINSIZE), request, HttpConstants.DEFAULT_CHARSET);
} }
@ -127,8 +126,7 @@ public class HttpPostStandardRequestDecoder implements InterfaceHttpPostRequestD
* if the default charset was wrong when decoding or other * if the default charset was wrong when decoding or other
* errors * errors
*/ */
public HttpPostStandardRequestDecoder(HttpDataFactory factory, HttpRequest request) public HttpPostStandardRequestDecoder(HttpDataFactory factory, HttpRequest request) {
throws ErrorDataDecoderException {
this(factory, request, HttpConstants.DEFAULT_CHARSET); this(factory, request, HttpConstants.DEFAULT_CHARSET);
} }
@ -146,8 +144,7 @@ public class HttpPostStandardRequestDecoder implements InterfaceHttpPostRequestD
* if the default charset was wrong when decoding or other * if the default charset was wrong when decoding or other
* errors * errors
*/ */
public HttpPostStandardRequestDecoder(HttpDataFactory factory, HttpRequest request, Charset charset) public HttpPostStandardRequestDecoder(HttpDataFactory factory, HttpRequest request, Charset charset) {
throws ErrorDataDecoderException {
if (factory == null) { if (factory == null) {
throw new NullPointerException("factory"); throw new NullPointerException("factory");
} }
@ -182,6 +179,7 @@ public class HttpPostStandardRequestDecoder implements InterfaceHttpPostRequestD
* *
* @return True if this request is a Multipart request * @return True if this request is a Multipart request
*/ */
@Override
public boolean isMultipart() { public boolean isMultipart() {
checkDestroyed(); checkDestroyed();
return false; return false;
@ -192,6 +190,7 @@ public class HttpPostStandardRequestDecoder implements InterfaceHttpPostRequestD
* Setting this lower gives lower memory usage but with the overhead of more memory copies. * Setting this lower gives lower memory usage but with the overhead of more memory copies.
* Use {@code 0} to disable it. * Use {@code 0} to disable it.
*/ */
@Override
public void setDiscardThreshold(int discardThreshold) { public void setDiscardThreshold(int discardThreshold) {
if (discardThreshold < 0) { if (discardThreshold < 0) {
throw new IllegalArgumentException("discardThreshold must be >= 0"); throw new IllegalArgumentException("discardThreshold must be >= 0");
@ -202,6 +201,7 @@ public class HttpPostStandardRequestDecoder implements InterfaceHttpPostRequestD
/** /**
* Return the threshold in bytes after which read data in the buffer should be discarded. * Return the threshold in bytes after which read data in the buffer should be discarded.
*/ */
@Override
public int getDiscardThreshold() { public int getDiscardThreshold() {
return discardThreshold; return discardThreshold;
} }
@ -216,7 +216,8 @@ public class HttpPostStandardRequestDecoder implements InterfaceHttpPostRequestD
* @throws NotEnoughDataDecoderException * @throws NotEnoughDataDecoderException
* Need more chunks * Need more chunks
*/ */
public List<InterfaceHttpData> getBodyHttpDatas() throws NotEnoughDataDecoderException { @Override
public List<InterfaceHttpData> getBodyHttpDatas() {
checkDestroyed(); checkDestroyed();
if (!isLastChunk) { if (!isLastChunk) {
@ -236,8 +237,8 @@ public class HttpPostStandardRequestDecoder implements InterfaceHttpPostRequestD
* @throws NotEnoughDataDecoderException * @throws NotEnoughDataDecoderException
* need more chunks * need more chunks
*/ */
public List<InterfaceHttpData> getBodyHttpDatas(String name) @Override
throws NotEnoughDataDecoderException { public List<InterfaceHttpData> getBodyHttpDatas(String name) {
checkDestroyed(); checkDestroyed();
if (!isLastChunk) { if (!isLastChunk) {
@ -258,7 +259,8 @@ public class HttpPostStandardRequestDecoder implements InterfaceHttpPostRequestD
* @throws NotEnoughDataDecoderException * @throws NotEnoughDataDecoderException
* need more chunks * need more chunks
*/ */
public InterfaceHttpData getBodyHttpData(String name) throws NotEnoughDataDecoderException { @Override
public InterfaceHttpData getBodyHttpData(String name) {
checkDestroyed(); checkDestroyed();
if (!isLastChunk) { if (!isLastChunk) {
@ -280,8 +282,8 @@ public class HttpPostStandardRequestDecoder implements InterfaceHttpPostRequestD
* if there is a problem with the charset decoding or other * if there is a problem with the charset decoding or other
* errors * errors
*/ */
public HttpPostStandardRequestDecoder offer(HttpContent content) @Override
throws ErrorDataDecoderException { public HttpPostStandardRequestDecoder offer(HttpContent content) {
checkDestroyed(); checkDestroyed();
// Maybe we should better not copy here for performance reasons but this will need // Maybe we should better not copy here for performance reasons but this will need
@ -313,7 +315,8 @@ public class HttpPostStandardRequestDecoder implements InterfaceHttpPostRequestD
* @throws EndOfDataDecoderException * @throws EndOfDataDecoderException
* No more data will be available * No more data will be available
*/ */
public boolean hasNext() throws EndOfDataDecoderException { @Override
public boolean hasNext() {
checkDestroyed(); checkDestroyed();
if (currentStatus == MultiPartStatus.EPILOGUE) { if (currentStatus == MultiPartStatus.EPILOGUE) {
@ -337,7 +340,8 @@ public class HttpPostStandardRequestDecoder implements InterfaceHttpPostRequestD
* @throws EndOfDataDecoderException * @throws EndOfDataDecoderException
* No more data will be available * No more data will be available
*/ */
public InterfaceHttpData next() throws EndOfDataDecoderException { @Override
public InterfaceHttpData next() {
checkDestroyed(); checkDestroyed();
if (hasNext()) { if (hasNext()) {
@ -353,7 +357,7 @@ public class HttpPostStandardRequestDecoder implements InterfaceHttpPostRequestD
* if there is a problem with the charset decoding or other * if there is a problem with the charset decoding or other
* errors * errors
*/ */
private void parseBody() throws ErrorDataDecoderException { private void parseBody() {
if (currentStatus == MultiPartStatus.PREEPILOGUE || currentStatus == MultiPartStatus.EPILOGUE) { if (currentStatus == MultiPartStatus.PREEPILOGUE || currentStatus == MultiPartStatus.EPILOGUE) {
if (isLastChunk) { if (isLastChunk) {
currentStatus = MultiPartStatus.EPILOGUE; currentStatus = MultiPartStatus.EPILOGUE;
@ -387,7 +391,7 @@ public class HttpPostStandardRequestDecoder implements InterfaceHttpPostRequestD
* if there is a problem with the charset decoding or other * if there is a problem with the charset decoding or other
* errors * errors
*/ */
private void parseBodyAttributesStandard() throws ErrorDataDecoderException { private void parseBodyAttributesStandard() {
int firstpos = undecodedChunk.readerIndex(); int firstpos = undecodedChunk.readerIndex();
int currentpos = firstpos; int currentpos = firstpos;
int equalpos; int equalpos;
@ -501,7 +505,7 @@ public class HttpPostStandardRequestDecoder implements InterfaceHttpPostRequestD
* if there is a problem with the charset decoding or other * if there is a problem with the charset decoding or other
* errors * errors
*/ */
private void parseBodyAttributes() throws ErrorDataDecoderException { private void parseBodyAttributes() {
SeekAheadOptimize sao; SeekAheadOptimize sao;
try { try {
sao = new SeekAheadOptimize(undecodedChunk); sao = new SeekAheadOptimize(undecodedChunk);
@ -623,7 +627,7 @@ public class HttpPostStandardRequestDecoder implements InterfaceHttpPostRequestD
} }
} }
private void setFinalBuffer(ByteBuf buffer) throws ErrorDataDecoderException, IOException { private void setFinalBuffer(ByteBuf buffer) throws IOException {
currentAttribute.addContent(buffer, true); currentAttribute.addContent(buffer, true);
String value = decodeAttribute(currentAttribute.getByteBuf().toString(charset), charset); String value = decodeAttribute(currentAttribute.getByteBuf().toString(charset), charset);
currentAttribute.setValue(value); currentAttribute.setValue(value);
@ -636,8 +640,7 @@ public class HttpPostStandardRequestDecoder implements InterfaceHttpPostRequestD
* *
* @return the decoded component * @return the decoded component
*/ */
private static String decodeAttribute(String s, Charset charset) private static String decodeAttribute(String s, Charset charset) {
throws ErrorDataDecoderException {
if (s == null) { if (s == null) {
return ""; return "";
} }
@ -652,10 +655,8 @@ public class HttpPostStandardRequestDecoder implements InterfaceHttpPostRequestD
/** /**
* Skip control Characters * Skip control Characters
*
* @throws NotEnoughDataDecoderException
*/ */
void skipControlCharacters() throws NotEnoughDataDecoderException { void skipControlCharacters() {
SeekAheadOptimize sao; SeekAheadOptimize sao;
try { try {
sao = new SeekAheadOptimize(undecodedChunk); sao = new SeekAheadOptimize(undecodedChunk);
@ -692,6 +693,7 @@ public class HttpPostStandardRequestDecoder implements InterfaceHttpPostRequestD
* Destroy the {@link HttpPostStandardRequestDecoder} and release all it resources. After this method * Destroy the {@link HttpPostStandardRequestDecoder} and release all it resources. After this method
* was called it is not possible to operate on it anymore. * was called it is not possible to operate on it anymore.
*/ */
@Override
public void destroy() { public void destroy() {
checkDestroyed(); checkDestroyed();
cleanFiles(); cleanFiles();
@ -711,6 +713,7 @@ public class HttpPostStandardRequestDecoder implements InterfaceHttpPostRequestD
/** /**
* Clean all HttpDatas (on Disk) for the current request. * Clean all HttpDatas (on Disk) for the current request.
*/ */
@Override
public void cleanFiles() { public void cleanFiles() {
checkDestroyed(); checkDestroyed();
@ -720,6 +723,7 @@ public class HttpPostStandardRequestDecoder implements InterfaceHttpPostRequestD
/** /**
* Remove the given FileUpload from the list of FileUploads to clean * Remove the given FileUpload from the list of FileUploads to clean
*/ */
@Override
public void removeHttpDataFromClean(InterfaceHttpData data) { public void removeHttpDataFromClean(InterfaceHttpData data) {
checkDestroyed(); checkDestroyed();