From 0488503a3a1af4fc7b7679e3f3457bf988c18701 Mon Sep 17 00:00:00 2001 From: Cheolsoo Park Date: Wed, 30 Jan 2013 17:10:28 -0800 Subject: [PATCH] SQOOP-855: pg_bulkload: NullPointerException will be thrown if user specified invalid path the binary (Jarek Jarcec Cecho via Cheolsoo Park) --- .../sqoop/mapreduce/PGBulkloadExportMapper.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/java/org/apache/sqoop/mapreduce/PGBulkloadExportMapper.java b/src/java/org/apache/sqoop/mapreduce/PGBulkloadExportMapper.java index 5ba2b6ba..86c5e02e 100644 --- a/src/java/org/apache/sqoop/mapreduce/PGBulkloadExportMapper.java +++ b/src/java/org/apache/sqoop/mapreduce/PGBulkloadExportMapper.java @@ -170,6 +170,7 @@ protected void setup(Context context) thread = new ReadThread(process.getErrorStream()); thread.start(); } catch (Exception e) { + LOG.error("Can't start up pg_bulkload process", e); cleanup(context); doExecuteUpdate("DROP TABLE " + tmpTableName); throw new IOException(e); @@ -200,10 +201,17 @@ protected void cleanup(Context context) LongWritable taskid = new LongWritable(context.getTaskAttemptID().getTaskID().getId()); context.write(taskid, new Text(tmpTableName)); - writer.close(); - out.close(); + + if (writer != null) { + writer.close(); + } + if (out != null) { + out.close(); + } try { - thread.join(); + if (thread != null) { + thread.join(); + } } finally { // block until the process is done. if (null != process) {