Skip to content

Commit 9cc4066

Browse files
author
Kevin Wilfong
committed
HIVE-2937. TestHiveServerSessions hangs when executed directly. (navis via kevinwilfong)
git-svn-id: https://svn.apache.org/repos/asf/hive/trunk@1325830 13f79535-47bb-0310-9956-ffa450edef68
1 parent 3a8e9ae commit 9cc4066

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -382,21 +382,22 @@ private void createDefaultDB_core(RawStore ms) throws MetaException, InvalidObje
382382
* @throws MetaException
383383
*/
384384
private void createDefaultDB() throws MetaException {
385-
if (HMSHandler.createDefaultDB || !checkForDefaultDb) {
386-
return;
387-
}
385+
synchronized (HMSHandler.class) {
386+
if (HMSHandler.createDefaultDB || !checkForDefaultDb) {
387+
return;
388+
}
388389

389-
try {
390-
createDefaultDB_core(getMS());
391-
} catch (InvalidObjectException e) {
392-
throw new MetaException(e.getMessage());
393-
} catch (MetaException e) {
394-
throw e;
395-
} catch (Exception e) {
396-
assert (e instanceof RuntimeException);
397-
throw (RuntimeException) e;
390+
try {
391+
createDefaultDB_core(getMS());
392+
} catch (InvalidObjectException e) {
393+
throw new MetaException(e.getMessage());
394+
} catch (MetaException e) {
395+
throw e;
396+
} catch (Exception e) {
397+
assert (e instanceof RuntimeException);
398+
throw (RuntimeException) e;
399+
}
398400
}
399-
400401
}
401402

402403
private void logInfo(String m) {

service/src/java/org/apache/hadoop/hive/service/HiveServer.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,11 @@ private void setupSessionIO(SessionState session) {
152152
session.in = null;
153153
session.out = new PrintStream(System.out, true, "UTF-8");
154154
session.err = new PrintStream(System.err, true, "UTF-8");
155-
} catch (UnsupportedEncodingException ee) {
156-
ee.printStackTrace();
157-
session.out = null;
158-
session.err = null;
159-
}
155+
} catch (UnsupportedEncodingException ee) {
156+
ee.printStackTrace();
157+
session.out = null;
158+
session.err = null;
159+
}
160160
}
161161
}
162162

@@ -545,11 +545,14 @@ public ThriftHiveProcessorFactory(TProcessor processor, HiveConf conf) {
545545
}
546546

547547
@Override
548+
@SuppressWarnings("unchecked")
548549
public TProcessor getProcessor(TTransport trans) {
549550
try {
550551
Iface handler = new HiveServerHandler(new HiveConf(conf));
551552
return new ThriftHive.Processor(handler);
552553
} catch (Exception e) {
554+
HiveServerHandler.LOG.warn("Failed to get processor by exception " + e, e);
555+
trans.close();
553556
throw new RuntimeException(e);
554557
}
555558
}

0 commit comments

Comments
 (0)