@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { if (cause instanceof IllegalArgumentException) { write(ctx, HttpResponseStatus.BAD_REQUEST, Optional.of(cause.getMessage())); } else { write(ctx, HttpResponseStatus.INTERNAL_SERVER_ERROR, Optional.of(Throwables.getStackTraceAsString(cause))); } } }
private static IOError getIOError(Throwable throwable) { IOError error = new IOErrorWithCause(throwable); error.setMessage(Throwables.getStackTraceAsString(throwable)); return error; }
@Override public void createTable(ByteBuffer in_tableName, List<ColumnDescriptor> columnFamilies) throws IOError, IllegalArgument, AlreadyExists { TableName tableName = getTableName(in_tableName); try { if (getAdmin().tableExists(tableName)) { throw new AlreadyExists("table name already in use"); } HTableDescriptor desc = new HTableDescriptor(tableName); for (ColumnDescriptor col : columnFamilies) { HColumnDescriptor colDesc = ThriftUtilities.colDescFromThrift(col); desc.addFamily(colDesc); } getAdmin().createTable(desc); } catch (IOException e) { LOG.warn(e.getMessage(), e); throw getIOError(e); } catch (IllegalArgumentException e) { LOG.warn(e.getMessage(), e); throw new IllegalArgument(Throwables.getStackTraceAsString(e)); } }
msg += "\nCause:\n" + Throwables.getStackTraceAsString(cause);
} catch (IllegalArgumentException e) { LOG.warn(e.getMessage(), e); throw new IllegalArgument(Throwables.getStackTraceAsString(e)); } finally{ closeTable(table);
} catch (IOException | IllegalArgumentException e) { LOG.warn(e.getMessage(), e); throw new IllegalArgument(Throwables.getStackTraceAsString(e)); } catch (IllegalArgumentException e) { LOG.warn(e.getMessage(), e); throw new IllegalArgument(Throwables.getStackTraceAsString(e)); } finally { closeTable(table);
@Test public void testNoSuchClass() throws IOException { List<CoprocessorViolation> violations = validateClass("NoSuchClass"); assertEquals(1, violations.size()); CoprocessorViolation violation = violations.get(0); assertEquals(getFullClassName("NoSuchClass"), violation.getClassName()); assertEquals(Severity.ERROR, violation.getSeverity()); String stackTrace = Throwables.getStackTraceAsString(violation.getThrowable()); assertTrue(stackTrace.contains("java.lang.ClassNotFoundException: " + "org.apache.hadoop.hbase.tool.coprocessor.CoprocessorValidatorTest$NoSuchClass")); }
@Test public void testTableNoSuchClass() throws IOException { List<CoprocessorViolation> violations = validateTable(null, "NoSuchClass"); assertEquals(1, violations.size()); CoprocessorViolation violation = violations.get(0); assertEquals(getFullClassName("NoSuchClass"), violation.getClassName()); assertEquals(Severity.ERROR, violation.getSeverity()); String stackTrace = Throwables.getStackTraceAsString(violation.getThrowable()); assertTrue(stackTrace.contains("java.lang.ClassNotFoundException: " + "org.apache.hadoop.hbase.tool.coprocessor.CoprocessorValidatorTest$NoSuchClass")); }
@Test public void testMissingClass() throws IOException { MissingClassClassLoader missingClassClassLoader = new MissingClassClassLoader(); List<CoprocessorViolation> violations = validateClass(missingClassClassLoader, "MissingClassObserver"); assertEquals(1, violations.size()); CoprocessorViolation violation = violations.get(0); assertEquals(getFullClassName("MissingClassObserver"), violation.getClassName()); assertEquals(Severity.ERROR, violation.getSeverity()); String stackTrace = Throwables.getStackTraceAsString(violation.getThrowable()); assertTrue(stackTrace.contains("java.lang.ClassNotFoundException: " + "org.apache.hadoop.hbase.tool.coprocessor.CoprocessorValidatorTest$MissingClass")); }
} catch (IllegalArgumentException e) { LOG.warn(e.getMessage(), e); throw new IllegalArgument(Throwables.getStackTraceAsString(e)); } finally{ closeTable(table);
@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { if (cause instanceof IllegalArgumentException) { write(ctx, HttpResponseStatus.BAD_REQUEST, Optional.of(cause.getMessage())); } else { write(ctx, HttpResponseStatus.INTERNAL_SERVER_ERROR, Optional.of(Throwables.getStackTraceAsString(cause))); } } }
private static IOError getIOError(Throwable throwable) { IOError error = new IOErrorWithCause(throwable); error.setMessage(Throwables.getStackTraceAsString(throwable)); return error; }
private static IOError getIOError(Throwable throwable) { IOError error = new IOErrorWithCause(throwable); error.setMessage(Throwables.getStackTraceAsString(throwable)); return error; }
@Override public void createTable(ByteBuffer in_tableName, List<ColumnDescriptor> columnFamilies) throws IOError, IllegalArgument, AlreadyExists { TableName tableName = getTableName(in_tableName); try { if (getAdmin().tableExists(tableName)) { throw new AlreadyExists("table name already in use"); } HTableDescriptor desc = new HTableDescriptor(tableName); for (ColumnDescriptor col : columnFamilies) { HColumnDescriptor colDesc = ThriftUtilities.colDescFromThrift(col); desc.addFamily(colDesc); } getAdmin().createTable(desc); } catch (IOException e) { LOG.warn(e.getMessage(), e); throw getIOError(e); } catch (IllegalArgumentException e) { LOG.warn(e.getMessage(), e); throw new IllegalArgument(Throwables.getStackTraceAsString(e)); } }
@Override public void createTable(ByteBuffer in_tableName, List<ColumnDescriptor> columnFamilies) throws IOError, IllegalArgument, AlreadyExists { TableName tableName = getTableName(in_tableName); try { if (getAdmin().tableExists(tableName)) { throw new AlreadyExists("table name already in use"); } HTableDescriptor desc = new HTableDescriptor(tableName); for (ColumnDescriptor col : columnFamilies) { HColumnDescriptor colDesc = ThriftUtilities.colDescFromThrift(col); desc.addFamily(colDesc); } getAdmin().createTable(desc); } catch (IOException e) { LOG.warn(e.getMessage(), e); throw getIOError(e); } catch (IllegalArgumentException e) { LOG.warn(e.getMessage(), e); throw new IllegalArgument(Throwables.getStackTraceAsString(e)); } }
} catch (IOException | IllegalArgumentException e) { LOG.warn(e.getMessage(), e); throw new IllegalArgument(Throwables.getStackTraceAsString(e)); } catch (IllegalArgumentException e) { LOG.warn(e.getMessage(), e); throw new IllegalArgument(Throwables.getStackTraceAsString(e)); } finally { closeTable(table);
} catch (IOException | IllegalArgumentException e) { LOG.warn(e.getMessage(), e); throw new IllegalArgument(Throwables.getStackTraceAsString(e)); } catch (IllegalArgumentException e) { LOG.warn(e.getMessage(), e); throw new IllegalArgument(Throwables.getStackTraceAsString(e)); } finally { closeTable(table);
@Test public void testNoSuchClass() throws IOException { List<CoprocessorViolation> violations = validateClass("NoSuchClass"); assertEquals(1, violations.size()); CoprocessorViolation violation = violations.get(0); assertEquals(getFullClassName("NoSuchClass"), violation.getClassName()); assertEquals(Severity.ERROR, violation.getSeverity()); String stackTrace = Throwables.getStackTraceAsString(violation.getThrowable()); assertTrue(stackTrace.contains("java.lang.ClassNotFoundException: " + "org.apache.hadoop.hbase.tool.coprocessor.CoprocessorValidatorTest$NoSuchClass")); }
@Test public void testTableNoSuchClass() throws IOException { List<CoprocessorViolation> violations = validateTable(null, "NoSuchClass"); assertEquals(1, violations.size()); CoprocessorViolation violation = violations.get(0); assertEquals(getFullClassName("NoSuchClass"), violation.getClassName()); assertEquals(Severity.ERROR, violation.getSeverity()); String stackTrace = Throwables.getStackTraceAsString(violation.getThrowable()); assertTrue(stackTrace.contains("java.lang.ClassNotFoundException: " + "org.apache.hadoop.hbase.tool.coprocessor.CoprocessorValidatorTest$NoSuchClass")); }
@Test public void testMissingClass() throws IOException { MissingClassClassLoader missingClassClassLoader = new MissingClassClassLoader(); List<CoprocessorViolation> violations = validateClass(missingClassClassLoader, "MissingClassObserver"); assertEquals(1, violations.size()); CoprocessorViolation violation = violations.get(0); assertEquals(getFullClassName("MissingClassObserver"), violation.getClassName()); assertEquals(Severity.ERROR, violation.getSeverity()); String stackTrace = Throwables.getStackTraceAsString(violation.getThrowable()); assertTrue(stackTrace.contains("java.lang.ClassNotFoundException: " + "org.apache.hadoop.hbase.tool.coprocessor.CoprocessorValidatorTest$MissingClass")); }