• Post Reply Bookmark Topic Watch Topic
  • New Topic

in multithreading application - file uploading task - 423 response code error  RSS feed

i mehta
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,

I am working on uploading files related funcitonality. Application is multithreading. Each

thread is uploading one or more files. All the threads are uploading to same folder. I am

using FTP, HTTP protocol. Sometimes it is failing. It is giving error of 423 - response code

(for http protocol). For FTP it is not giving some detailed error. But I guess it is due to

same reason. 423 response code is for Locking.

Here is my code snippet:


HttpURLConnection conn = null;


this.sendCommand(conn, HTTP_PUT, local.length());

// pipe the file data to the output stream
out = conn.getOutputStream();
this.pipeData(file, out);

int code = conn.getResponseCode();
if(code < 300) {
logger.debug("for a PUT, the response code is - "+code);
ret = true;
} else {
// for a PUT, the response code should not be 3xx or higher
logger.error("for a PUT, the response code is - "+code+" response message -- "+conn.getResponseMessage());
// no need to throw an exception

code for pipeData method: - which has logic for uploading data

int pipeData(InputStream from, OutputStream to) throws IOException {
int bytesRead = 0;

if(from == null) {
logger.error("null input stream");
throw new IOException("null input stream");

if(to == null) {
logger.error("null outputstream");
throw new IOException("null output stream");

byte[] data = new byte[MAX_FILE_SIZE];
int size = 0;

while((size = from.read(data)) > 0) {
bytesRead += size;
to.write(data, 0, size);

// input/output streams should be closed by calling party.

return bytesRead;

Can any body throw some light?

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!