diff --git a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryArrowArray.java b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryArrowArray.java index a697023a19bc..642f86b799f3 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryArrowArray.java +++ b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryArrowArray.java @@ -41,7 +41,7 @@ public BigQueryArrowArray(Field schema, JsonStringArrayList values) { @Override public Object getArray() { - LOG.finestTrace("getArray", "++enter++"); + LOG.finestTrace("getArray"); ensureValid(); if (values == null) { return null; @@ -51,7 +51,7 @@ public Object getArray() { @Override public Object getArray(long index, int count) { - LOG.finestTrace("getArray", "++enter++"); + LOG.finestTrace("getArray"); ensureValid(); if (values == null) { return null; @@ -62,7 +62,7 @@ public Object getArray(long index, int count) { @Override public ResultSet getResultSet() throws SQLException { - LOG.finestTrace("getResultSet", "++enter++"); + LOG.finestTrace("getResultSet"); ensureValid(); if (values == null) { return new BigQueryArrowResultSet(); @@ -75,7 +75,7 @@ public ResultSet getResultSet() throws SQLException { @Override public ResultSet getResultSet(long index, int count) throws SQLException { - LOG.finestTrace("getResultSet", "++enter++"); + LOG.finestTrace("getResultSet"); ensureValid(); if (values == null) { return new BigQueryArrowResultSet(); @@ -89,14 +89,14 @@ public ResultSet getResultSet(long index, int count) throws SQLException { @Override public void free() { - LOG.finestTrace("free", "++enter++"); + LOG.finestTrace("free"); this.values = null; markInvalid(); } @Override Object getCoercedValue(int index) { - LOG.finestTrace("getCoercedValue", "++enter++"); + LOG.finestTrace("getCoercedValue"); Object value = this.values.get(index); return this.arrayOfStruct ? new BigQueryArrowStruct(schema.getSubFields(), (JsonStringHashMap) value) diff --git a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryArrowBatchWrapper.java b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryArrowBatchWrapper.java index 99781ff16b70..66d35f6c460e 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryArrowBatchWrapper.java +++ b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryArrowBatchWrapper.java @@ -21,8 +21,6 @@ /** This class acts as a facade layer and wraps Arrow's VectorSchemaRoot & JsonStringArrayList */ class BigQueryArrowBatchWrapper { - private static final BigQueryJdbcCustomLogger LOG = - new BigQueryJdbcCustomLogger(BigQueryArrowBatchWrapper.class.getName()); // Reference to the current arrowBatch private final ArrowRecordBatch currentArrowBatch; // Reference to the nested Records, set as null otherwise (Arrays) @@ -45,35 +43,29 @@ private BigQueryArrowBatchWrapper( } static BigQueryArrowBatchWrapper of(ArrowRecordBatch currentArrowBatch, boolean... isLast) { - LOG.finest("++enter++"); boolean isLastFlag = isLast != null && isLast.length == 1 && isLast[0]; return new BigQueryArrowBatchWrapper(currentArrowBatch, null, isLastFlag, null); } static BigQueryArrowBatchWrapper getNestedFieldValueListWrapper( JsonStringArrayList nestedRecords, boolean... isLast) { - LOG.finest("++enter++"); boolean isLastFlag = isLast != null && isLast.length == 1 && isLast[0]; return new BigQueryArrowBatchWrapper(null, nestedRecords, isLastFlag, null); } static BigQueryArrowBatchWrapper ofError(Exception exception) { - LOG.finest("++enter++"); return new BigQueryArrowBatchWrapper(null, null, true, exception); } ArrowRecordBatch getCurrentArrowBatch() { - LOG.finest("++enter++"); return this.currentArrowBatch; } JsonStringArrayList getNestedRecords() { - LOG.finest("++enter++"); return this.nestedRecords; } boolean isLast() { - LOG.finest("++enter++"); return this.isLast; } diff --git a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryArrowResultSet.java b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryArrowResultSet.java index 9cdf3dfd98c2..3f5ae77507bb 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryArrowResultSet.java +++ b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryArrowResultSet.java @@ -96,7 +96,7 @@ private BigQueryArrowResultSet( BigQuery bigQuery) throws SQLException { super(bigQuery, statement, schema, isNested); - LOG.finestTrace("", "++enter++"); + LOG.finestTrace(""); this.totalRows = totalRows; this.buffer = buffer; this.currentNestedBatch = currentNestedBatch; @@ -181,7 +181,7 @@ private ArrowDeserializer(ArrowSchema arrowSchema) throws IOException { } private void deserializeArrowBatch(ArrowRecordBatch batch) throws SQLException { - LOG.finestTrace("deserializeArrowBatch", "++enter++"); + LOG.finestTrace("deserializeArrowBatch"); try { if (vectorSchemaRoot != null) { // Clear vectorSchemaRoot before populating a new batch @@ -276,7 +276,7 @@ else if (this.currentBatchRowIndex < this.vectorSchemaRoot.getRowCount()) { } private Object getObjectInternal(int columnIndex) throws SQLException { - LOG.finestTrace("getObjectInternal", "++enter++"); + LOG.finestTrace("getObjectInternal"); checkClosed(); Object value; if (this.isNested) { @@ -318,7 +318,7 @@ private Object getObjectInternal(int columnIndex) throws SQLException { public Object getObject(int columnIndex) throws SQLException { // columnIndex is SQL index starting at 1 - LOG.finestTrace("getObject", "++enter++"); + LOG.finestTrace("getObject"); checkClosed(); Object value = getObjectInternal(columnIndex); if (value == null) { @@ -460,7 +460,7 @@ public void close() { @Override public boolean isBeforeFirst() throws SQLException { - LOG.finestTrace("isBeforeFirst", "++enter++"); + LOG.finestTrace("isBeforeFirst"); checkClosed(); if (this.isNested) { return this.nestedRowIndex < this.fromIndex; @@ -471,14 +471,14 @@ public boolean isBeforeFirst() throws SQLException { @Override public boolean isAfterLast() throws SQLException { - LOG.finestTrace("isAfterLast", "++enter++"); + LOG.finestTrace("isAfterLast"); checkClosed(); return this.afterLast; } @Override public boolean isFirst() throws SQLException { - LOG.finestTrace("isFirst", "++enter++"); + LOG.finestTrace("isFirst"); checkClosed(); if (this.isNested) { return this.nestedRowIndex == this.fromIndex; @@ -489,7 +489,7 @@ public boolean isFirst() throws SQLException { @Override public boolean isLast() throws SQLException { - LOG.finestTrace("isLast", "++enter++"); + LOG.finestTrace("isLast"); checkClosed(); if (this.isNested) { return this.nestedRowIndex == this.toIndexExclusive - 1; diff --git a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryArrowStruct.java b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryArrowStruct.java index 54ca4cb96547..3968d50c83ee 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryArrowStruct.java +++ b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryArrowStruct.java @@ -52,7 +52,7 @@ FieldList getSchema() { @Override public Object[] getAttributes() { - LOG.finestTrace("getAttributes", "++enter++"); + LOG.finestTrace("getAttributes"); int size = this.schema.size(); Object[] attributes = (Object[]) Array.newInstance(Object.class, size); @@ -71,7 +71,7 @@ public Object[] getAttributes() { } private Object getValue(Field currentSchema, Object currentValue) { - LOG.finestTrace("getValue", "++enter++"); + LOG.finestTrace("getValue"); if (isArray(currentSchema)) { return new BigQueryArrowArray(currentSchema, (JsonStringArrayList) currentValue); } else if (isStruct(currentSchema)) { diff --git a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryBaseArray.java b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryBaseArray.java index a48a3b25d141..4259a3588273 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryBaseArray.java +++ b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryBaseArray.java @@ -56,14 +56,14 @@ abstract class BigQueryBaseArray implements java.sql.Array { @Override public final String getBaseTypeName() { - LOG.finestTrace("getBaseTypeName", "++enter++"); + LOG.finestTrace("getBaseTypeName"); ensureValid(); return this.schema.getType().getStandardType().name(); } @Override public final int getBaseType() { - LOG.finestTrace("getBaseType", "++enter++"); + LOG.finestTrace("getBaseType"); ensureValid(); return BigQueryJdbcTypeMappings.standardSQLToJavaSqlTypesMapping.get( schema.getType().getStandardType()); @@ -92,7 +92,7 @@ public final ResultSet getResultSet(long index, int count, Map> } protected Object getArrayInternal(int fromIndex, int toIndexExclusive) { - LOG.finestTrace("getArrayInternal", "++enter++"); + LOG.finestTrace("getArrayInternal"); Class targetClass = getTargetClass(); int size = toIndexExclusive - fromIndex; Object javaArray = Array.newInstance(targetClass, size); @@ -104,7 +104,7 @@ protected Object getArrayInternal(int fromIndex, int toIndexExclusive) { } protected void ensureValid() throws IllegalStateException { - LOG.finestTrace("ensureValid", "++enter++"); + LOG.finestTrace("ensureValid"); if (!this.valid) { IllegalStateException ex = new IllegalStateException(INVALID_ARRAY); LOG.severe(INVALID_ARRAY, ex); @@ -113,19 +113,19 @@ protected void ensureValid() throws IllegalStateException { } protected void markInvalid() { - LOG.finestTrace("markInvalid", "++enter++"); + LOG.finestTrace("markInvalid"); this.schema = null; this.valid = false; } protected Field singleElementSchema() { - LOG.finestTrace("singleElementSchema", "++enter++"); + LOG.finestTrace("singleElementSchema"); return this.schema.toBuilder().setMode(Mode.REQUIRED).build(); } protected Tuple createRange(long index, int count, int size) throws IllegalStateException { - LOG.finestTrace("createRange", "++enter++"); + LOG.finestTrace("createRange"); // jdbc array follows 1 based array indexing long normalisedFromIndex = index - 1; if (normalisedFromIndex + count > size) { @@ -142,7 +142,7 @@ protected Tuple createRange(long index, int count, int size) } protected Class getTargetClass() { - LOG.finestTrace("getTargetClass", "++enter++"); + LOG.finestTrace("getTargetClass"); return this.arrayOfStruct ? Struct.class : BigQueryJdbcTypeMappings.standardSQLToJavaTypeMapping.get( @@ -152,7 +152,7 @@ protected Class getTargetClass() { abstract Object getCoercedValue(int index); static boolean isArray(Field currentSchema) { - LOG.finestTrace("isArray", "++enter++"); + LOG.finestTrace("isArray"); return currentSchema.getMode() == REPEATED; } diff --git a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryBaseResultSet.java b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryBaseResultSet.java index 09d96a196b94..aa035aae4641 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryBaseResultSet.java +++ b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryBaseResultSet.java @@ -247,7 +247,7 @@ public boolean isClosed() { public abstract Object getObject(int columnIndex) throws SQLException; protected int getColumnIndex(String columnLabel) throws SQLException { - LOG.finestTrace("getColumnIndex", "++enter++"); + LOG.finestTrace("getColumnIndex"); checkClosed(); if (columnLabel == null) { throw logAndCreateException("Column label cannot be null"); @@ -258,7 +258,7 @@ protected int getColumnIndex(String columnLabel) throws SQLException { @Override public String getString(int columnIndex) throws SQLException { - LOG.finestTrace("getString", "++enter++"); + LOG.finestTrace("getString"); try { Object value = getObject(columnIndex); return this.bigQueryTypeCoercer.coerceTo(String.class, value); @@ -269,7 +269,7 @@ public String getString(int columnIndex) throws SQLException { @Override public boolean getBoolean(int columnIndex) throws SQLException { - LOG.finestTrace("getBoolean", "++enter++"); + LOG.finestTrace("getBoolean"); StandardSQLTypeName type = getStandardSQLTypeName(columnIndex); if (type == StandardSQLTypeName.GEOGRAPHY @@ -288,7 +288,7 @@ public boolean getBoolean(int columnIndex) throws SQLException { @Override public byte getByte(int columnIndex) throws SQLException { - LOG.finestTrace("getByte", "++enter++"); + LOG.finestTrace("getByte"); try { Object value = getObject(columnIndex); return this.bigQueryTypeCoercer.coerceTo(Byte.class, value); @@ -299,7 +299,7 @@ public byte getByte(int columnIndex) throws SQLException { @Override public short getShort(int columnIndex) throws SQLException { - LOG.finestTrace("getShort", "++enter++"); + LOG.finestTrace("getShort"); try { Object value = getObject(columnIndex); return this.bigQueryTypeCoercer.coerceTo(Short.class, value); @@ -310,7 +310,7 @@ public short getShort(int columnIndex) throws SQLException { @Override public int getInt(int columnIndex) throws SQLException { - LOG.finestTrace("getInt", "++enter++"); + LOG.finestTrace("getInt"); try { Object value = getObject(columnIndex); return this.bigQueryTypeCoercer.coerceTo(Integer.class, value); @@ -321,7 +321,7 @@ public int getInt(int columnIndex) throws SQLException { @Override public long getLong(int columnIndex) throws SQLException { - LOG.finestTrace("getLong", "++enter++"); + LOG.finestTrace("getLong"); try { Object value = getObject(columnIndex); return this.bigQueryTypeCoercer.coerceTo(Long.class, value); @@ -332,7 +332,7 @@ public long getLong(int columnIndex) throws SQLException { @Override public float getFloat(int columnIndex) throws SQLException { - LOG.finestTrace("getFloat", "++enter++"); + LOG.finestTrace("getFloat"); try { Object value = getObject(columnIndex); return this.bigQueryTypeCoercer.coerceTo(Float.class, value); @@ -343,7 +343,7 @@ public float getFloat(int columnIndex) throws SQLException { @Override public double getDouble(int columnIndex) throws SQLException { - LOG.finestTrace("getDouble", "++enter++"); + LOG.finestTrace("getDouble"); try { Object value = getObject(columnIndex); return this.bigQueryTypeCoercer.coerceTo(Double.class, value); @@ -356,7 +356,7 @@ public double getDouble(int columnIndex) throws SQLException { @Deprecated @SuppressWarnings("deprecation") public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException { - LOG.finestTrace("getBigDecimal", "++enter++"); + LOG.finestTrace("getBigDecimal"); try { Object value = getObject(columnIndex); return this.bigQueryTypeCoercer.coerceTo(BigDecimal.class, value); @@ -367,7 +367,7 @@ public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException @Override public byte[] getBytes(int columnIndex) throws SQLException { - LOG.finestTrace("getBytes", "++enter++"); + LOG.finestTrace("getBytes"); try { Object value = getObject(columnIndex); return this.bigQueryTypeCoercer.coerceTo(byte[].class, value); @@ -378,7 +378,7 @@ public byte[] getBytes(int columnIndex) throws SQLException { @Override public Date getDate(int columnIndex) throws SQLException { - LOG.finestTrace("getDate", "++enter++"); + LOG.finestTrace("getDate"); try { Object value = getObject(columnIndex); return this.bigQueryTypeCoercer.coerceTo(java.sql.Date.class, value); @@ -389,7 +389,7 @@ public Date getDate(int columnIndex) throws SQLException { @Override public Time getTime(int columnIndex) throws SQLException { - LOG.finestTrace("getTime", "++enter++"); + LOG.finestTrace("getTime"); StandardSQLTypeName type = getStandardSQLTypeName(columnIndex); if (type == StandardSQLTypeName.INT64) { throw createCoercionException(columnIndex, java.sql.Time.class, null); @@ -404,7 +404,7 @@ public Time getTime(int columnIndex) throws SQLException { @Override public Timestamp getTimestamp(int columnIndex) throws SQLException { - LOG.finestTrace("getTimestamp", "++enter++"); + LOG.finestTrace("getTimestamp"); StandardSQLTypeName type = getStandardSQLTypeName(columnIndex); if (type == StandardSQLTypeName.INT64) { throw createCoercionException(columnIndex, java.sql.Timestamp.class, null); @@ -419,7 +419,7 @@ public Timestamp getTimestamp(int columnIndex) throws SQLException { @Override public BigDecimal getBigDecimal(int columnIndex) throws SQLException { - LOG.finestTrace("getBigDecimal", "++enter++"); + LOG.finestTrace("getBigDecimal"); try { Object value = getObject(columnIndex); return this.bigQueryTypeCoercer.coerceTo(BigDecimal.class, value); @@ -430,7 +430,7 @@ public BigDecimal getBigDecimal(int columnIndex) throws SQLException { @Override public Array getArray(int columnIndex) throws SQLException { - LOG.finestTrace("getArray", "++enter++"); + LOG.finestTrace("getArray"); try { return (Array) getObject(columnIndex); } catch (ClassCastException e) { @@ -440,27 +440,27 @@ public Array getArray(int columnIndex) throws SQLException { @Override public Blob getBlob(int columnIndex) throws SQLException { - LOG.finestTrace("getBlob", "++enter++"); + LOG.finestTrace("getBlob"); byte[] value = getBytes(columnIndex); return new javax.sql.rowset.serial.SerialBlob(value); } @Override public Clob getClob(int columnIndex) throws SQLException { - LOG.finestTrace("getClob", "++enter++"); + LOG.finestTrace("getClob"); String value = getString(columnIndex); return new javax.sql.rowset.serial.SerialClob(value.toCharArray()); } @Override public Reader getCharacterStream(int columnIndex) throws SQLException { - LOG.finestTrace("getCharacterStream", "++enter++"); + LOG.finestTrace("getCharacterStream"); String value = getString(columnIndex); return value == null ? null : new StringReader(value); } private InputStream getInputStream(String value, java.nio.charset.Charset charset) { - LOG.finestTrace("getInputStream", "++enter++"); + LOG.finestTrace("getInputStream"); if (value == null) { return null; } @@ -469,7 +469,7 @@ private InputStream getInputStream(String value, java.nio.charset.Charset charse @Override public InputStream getAsciiStream(int columnIndex) throws SQLException { - LOG.finestTrace("getAsciiStream", "++enter++"); + LOG.finestTrace("getAsciiStream"); return getInputStream(getString(columnIndex), StandardCharsets.US_ASCII); } @@ -477,20 +477,20 @@ public InputStream getAsciiStream(int columnIndex) throws SQLException { @Deprecated @SuppressWarnings("deprecation") public InputStream getUnicodeStream(int columnIndex) throws SQLException { - LOG.finestTrace("getUnicodeStream", "++enter++"); + LOG.finestTrace("getUnicodeStream"); return getInputStream(getString(columnIndex), StandardCharsets.UTF_16LE); } @Override public InputStream getBinaryStream(int columnIndex) throws SQLException { - LOG.finestTrace("getBinaryStream", "++enter++"); + LOG.finestTrace("getBinaryStream"); byte[] bytes = getBytes(columnIndex); return bytes == null ? null : new java.io.ByteArrayInputStream(bytes); } @Override public Date getDate(int columnIndex, Calendar cal) throws SQLException { - LOG.finestTrace("getDate", "++enter++"); + LOG.finestTrace("getDate"); Date date = getDate(columnIndex); if (date == null || cal == null) { return null; @@ -501,7 +501,7 @@ public Date getDate(int columnIndex, Calendar cal) throws SQLException { @Override public Time getTime(int columnIndex, Calendar cal) throws SQLException { - LOG.finestTrace("getTime", "++enter++"); + LOG.finestTrace("getTime"); Time time = getTime(columnIndex); if (time == null || cal == null) { return null; @@ -512,7 +512,7 @@ public Time getTime(int columnIndex, Calendar cal) throws SQLException { @Override public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException { - LOG.finestTrace("getTimestamp", "++enter++"); + LOG.finestTrace("getTimestamp"); Timestamp timeStamp = getTimestamp(columnIndex); if (timeStamp == null || cal == null) { return null; @@ -523,7 +523,7 @@ public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException @Override public int findColumn(String columnLabel) throws SQLException { - LOG.finestTrace("findColumn", "++enter++"); + LOG.finestTrace("findColumn"); return getColumnIndex(columnLabel); } diff --git a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryBaseStruct.java b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryBaseStruct.java index d516c938303d..20839d4b2dac 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryBaseStruct.java +++ b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryBaseStruct.java @@ -52,7 +52,7 @@ public final Object[] getAttributes(Map> map) throws SQLExcepti } static boolean isStruct(Field currentSchema) { - LOG.finestTrace("isStruct", "++enter++"); + LOG.finestTrace("isStruct"); return currentSchema.getType().getStandardType() == STRUCT; } diff --git a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryCallableStatement.java b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryCallableStatement.java index 260c35f8af1f..5223b26d2a14 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryCallableStatement.java +++ b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryCallableStatement.java @@ -66,7 +66,6 @@ protected BigQueryParameterHandler getParameterHandler() { @Override public Array getArray(int arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof Array) { return (Array) param; @@ -79,7 +78,6 @@ public Array getArray(int arg0) throws SQLException { @Override public Array getArray(String arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof Array) { return (Array) param; @@ -92,7 +90,6 @@ public Array getArray(String arg0) throws SQLException { @Override public BigDecimal getBigDecimal(int arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof BigDecimal) { return (BigDecimal) param; @@ -105,7 +102,6 @@ public BigDecimal getBigDecimal(int arg0) throws SQLException { @Override public BigDecimal getBigDecimal(String arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof BigDecimal) { return (BigDecimal) param; @@ -120,13 +116,11 @@ public BigDecimal getBigDecimal(String arg0) throws SQLException { @Deprecated @SuppressWarnings("deprecation") public BigDecimal getBigDecimal(int arg0, int arg1) throws SQLException { - LOG.finest("++enter++"); return getBigDecimal(arg0); } @Override public Blob getBlob(int arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof Blob) { return (Blob) param; @@ -139,7 +133,6 @@ public Blob getBlob(int arg0) throws SQLException { @Override public Blob getBlob(String arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof Blob) { return (Blob) param; @@ -152,7 +145,6 @@ public Blob getBlob(String arg0) throws SQLException { @Override public boolean getBoolean(int arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof Boolean) { return (Boolean) param; @@ -165,7 +157,6 @@ public boolean getBoolean(int arg0) throws SQLException { @Override public boolean getBoolean(String arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof Boolean) { return (Boolean) param; @@ -178,7 +169,6 @@ public boolean getBoolean(String arg0) throws SQLException { @Override public byte getByte(int arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof Byte) { return (Byte) param; @@ -191,7 +181,6 @@ public byte getByte(int arg0) throws SQLException { @Override public byte getByte(String arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof Byte) { return (Byte) param; @@ -204,7 +193,6 @@ public byte getByte(String arg0) throws SQLException { @Override public byte[] getBytes(int arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof byte[] || param.getClass().isAssignableFrom(byte[].class)) { return (byte[]) param; @@ -217,7 +205,6 @@ public byte[] getBytes(int arg0) throws SQLException { @Override public byte[] getBytes(String arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof byte[] || param.getClass().isAssignableFrom(byte[].class)) { return (byte[]) param; @@ -231,7 +218,6 @@ public byte[] getBytes(String arg0) throws SQLException { // FilterReader, InputStreamReader, PipedReader, StringReader @Override public Reader getCharacterStream(int arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof String || param.getClass().isAssignableFrom(String.class)) { return new StringReader(param.toString()); @@ -283,7 +269,6 @@ public Reader getCharacterStream(int arg0) throws SQLException { @Override public Reader getCharacterStream(String arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof String || param.getClass().isAssignableFrom(String.class)) { return new StringReader(param.toString()); @@ -335,7 +320,6 @@ public Reader getCharacterStream(String arg0) throws SQLException { @Override public Clob getClob(int arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof Clob) { return (Clob) param; @@ -348,7 +332,6 @@ public Clob getClob(int arg0) throws SQLException { @Override public Clob getClob(String arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof Clob) { return (Clob) param; @@ -361,7 +344,6 @@ public Clob getClob(String arg0) throws SQLException { @Override public Date getDate(int arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof Date) { return (Date) param; @@ -374,7 +356,6 @@ public Date getDate(int arg0) throws SQLException { @Override public Date getDate(String arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof Date) { return (Date) param; @@ -387,7 +368,6 @@ public Date getDate(String arg0) throws SQLException { @Override public Date getDate(int arg0, Calendar arg1) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof Date) { Date dateParam = (Date) param; @@ -408,7 +388,6 @@ public Date getDate(int arg0, Calendar arg1) throws SQLException { @Override public Date getDate(String arg0, Calendar arg1) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof Date) { Date dateParam = (Date) param; @@ -429,7 +408,6 @@ public Date getDate(String arg0, Calendar arg1) throws SQLException { @Override public double getDouble(int arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof Double) { return (Double) param; @@ -442,7 +420,6 @@ public double getDouble(int arg0) throws SQLException { @Override public double getDouble(String arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof Double) { return (Double) param; @@ -455,7 +432,6 @@ public double getDouble(String arg0) throws SQLException { @Override public float getFloat(int arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof Float) { return (Float) param; @@ -468,7 +444,6 @@ public float getFloat(int arg0) throws SQLException { @Override public float getFloat(String arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof Float) { return (Float) param; @@ -481,7 +456,6 @@ public float getFloat(String arg0) throws SQLException { @Override public int getInt(int arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof Integer) { return (Integer) param; @@ -494,7 +468,6 @@ public int getInt(int arg0) throws SQLException { @Override public int getInt(String arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof Integer) { return (Integer) param; @@ -507,7 +480,6 @@ public int getInt(String arg0) throws SQLException { @Override public long getLong(int arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof Long) { return (Long) param; @@ -526,7 +498,6 @@ public long getLong(int arg0) throws SQLException { @Override public long getLong(String arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof Long) { return (Long) param; @@ -545,19 +516,16 @@ public long getLong(String arg0) throws SQLException { @Override public Reader getNCharacterStream(int arg0) throws SQLException { - LOG.finest("++enter++"); return getCharacterStream(arg0); } @Override public Reader getNCharacterStream(String arg0) throws SQLException { - LOG.finest("++enter++"); return getCharacterStream(arg0); } @Override public NClob getNClob(int arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof NClob) {} if (param.getClass().isAssignableFrom(NClob.class)) { @@ -568,7 +536,6 @@ public NClob getNClob(int arg0) throws SQLException { @Override public NClob getNClob(String arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof NClob) { return (NClob) param; @@ -581,7 +548,6 @@ public NClob getNClob(String arg0) throws SQLException { @Override public String getNString(int arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof String) { return param.toString(); @@ -594,7 +560,6 @@ public String getNString(int arg0) throws SQLException { @Override public String getNString(String arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof String) { return param.toString(); @@ -607,19 +572,16 @@ public String getNString(String arg0) throws SQLException { @Override public Object getObject(int arg0) throws SQLException { - LOG.finest("++enter++"); return this.parameterHandler.getParameter(arg0); } @Override public Object getObject(String arg0) throws SQLException { - LOG.finest("++enter++"); return this.parameterHandler.getParameter(arg0); } @Override public Object getObject(int arg0, Map> arg1) throws SQLException { - LOG.finest("++enter++"); String paramKey = this.parameterHandler.getSqlType(arg0).name(); if (arg1.containsKey(paramKey)) { Class argJavaType = arg1.get(paramKey); @@ -633,7 +595,6 @@ public Object getObject(int arg0, Map> arg1) throws SQLExceptio @Override public Object getObject(String arg0, Map> arg1) throws SQLException { - LOG.finest("++enter++"); String paramKey = this.parameterHandler.getSqlType(arg0).name(); if (arg1.containsKey(paramKey)) { Class argJavaType = arg1.get(paramKey); @@ -647,7 +608,6 @@ public Object getObject(String arg0, Map> arg1) throws SQLExcep @Override public T getObject(int arg0, Class arg1) throws SQLException { - LOG.finest("++enter++"); Class javaType = this.parameterHandler.getType(arg0); if (javaType.isAssignableFrom(arg1)) { return (T) this.parameterHandler.getParameter(arg0); @@ -657,7 +617,6 @@ public T getObject(int arg0, Class arg1) throws SQLException { @Override public T getObject(String arg0, Class arg1) throws SQLException { - LOG.finest("++enter++"); Class javaType = this.parameterHandler.getType(arg0); if (javaType.isAssignableFrom(arg1)) { return (T) this.parameterHandler.getParameter(arg0); @@ -679,7 +638,6 @@ public Ref getRef(String arg0) throws SQLException { @Override public RowId getRowId(int arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof RowId) { return (RowId) param; @@ -692,7 +650,6 @@ public RowId getRowId(int arg0) throws SQLException { @Override public RowId getRowId(String arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof RowId) { return (RowId) param; @@ -717,7 +674,6 @@ public SQLXML getSQLXML(String arg0) throws SQLException { @Override public short getShort(int arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof Short) { return (Short) param; @@ -730,7 +686,6 @@ public short getShort(int arg0) throws SQLException { @Override public short getShort(String arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof Short) { return (Short) param; @@ -743,7 +698,6 @@ public short getShort(String arg0) throws SQLException { @Override public String getString(int arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof String) { return param.toString(); @@ -756,7 +710,6 @@ public String getString(int arg0) throws SQLException { @Override public String getString(String arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof String) { return param.toString(); @@ -769,7 +722,6 @@ public String getString(String arg0) throws SQLException { @Override public Time getTime(int arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof Time) { return (Time) param; @@ -782,7 +734,6 @@ public Time getTime(int arg0) throws SQLException { @Override public Time getTime(String arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof Time) { return (Time) param; @@ -795,7 +746,6 @@ public Time getTime(String arg0) throws SQLException { @Override public Time getTime(int arg0, Calendar arg1) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof Time) { Time timeParam = (Time) param; @@ -816,7 +766,6 @@ public Time getTime(int arg0, Calendar arg1) throws SQLException { @Override public Time getTime(String arg0, Calendar arg1) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof Time) { Time timeParam = (Time) param; @@ -837,7 +786,6 @@ public Time getTime(String arg0, Calendar arg1) throws SQLException { @Override public Timestamp getTimestamp(int arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof Timestamp) { return (Timestamp) param; @@ -850,7 +798,6 @@ public Timestamp getTimestamp(int arg0) throws SQLException { @Override public Timestamp getTimestamp(String arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof Timestamp) { return (Timestamp) param; @@ -863,7 +810,6 @@ public Timestamp getTimestamp(String arg0) throws SQLException { @Override public Timestamp getTimestamp(int arg0, Calendar arg1) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof Timestamp) { Timestamp timestampParam = (Timestamp) param; @@ -884,7 +830,6 @@ public Timestamp getTimestamp(int arg0, Calendar arg1) throws SQLException { @Override public Timestamp getTimestamp(String arg0, Calendar arg1) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof Timestamp) { Timestamp timestampParam = (Timestamp) param; @@ -905,7 +850,6 @@ public Timestamp getTimestamp(String arg0, Calendar arg1) throws SQLException { @Override public URL getURL(int arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof URL) { return (URL) param; @@ -918,7 +862,6 @@ public URL getURL(int arg0) throws SQLException { @Override public URL getURL(String arg0) throws SQLException { - LOG.finest("++enter++"); Object param = this.parameterHandler.getParameter(arg0); if (param instanceof URL) { return (URL) param; @@ -931,8 +874,7 @@ public URL getURL(String arg0) throws SQLException { @Override public void registerOutParameter(int paramIndex, int sqlType) throws SQLException { - LOG.finest("++enter++"); - LOG.finest("registerOutParameter: paramIndex %s, sqlType %s", paramIndex, sqlType); + LOG.finer("registerOutParameter: paramIndex %s, sqlType %s", paramIndex, sqlType); checkClosed(); try { this.parameterHandler.setParameter( @@ -950,8 +892,7 @@ public void registerOutParameter(int paramIndex, int sqlType) throws SQLExceptio @Override public void registerOutParameter(String paramName, int sqlType) throws SQLException { - LOG.finest("++enter++"); - LOG.finest("registerOutParameter: paramName %s, sqlType %s", paramName, sqlType); + LOG.finer("registerOutParameter: paramName %s, sqlType %s", paramName, sqlType); checkClosed(); try { this.parameterHandler.setParameter( @@ -969,8 +910,7 @@ public void registerOutParameter(String paramName, int sqlType) throws SQLExcept @Override public void registerOutParameter(int paramIndex, int sqlType, int scale) throws SQLException { - LOG.finest("++enter++"); - LOG.finest( + LOG.finer( "registerOutParameter: paramIndex %s, sqlType %s, scale %s", paramIndex, sqlType, scale); checkClosed(); if (sqlType != Types.NUMERIC && sqlType != Types.DECIMAL) { @@ -997,8 +937,7 @@ public void registerOutParameter(int paramIndex, int sqlType, int scale) throws @Override public void registerOutParameter(int paramIndex, int sqlType, String typeName) throws SQLException { - LOG.finest("++enter++"); - LOG.finest( + LOG.finer( "registerOutParameter: paramIndex %s, sqlType %s, typeName %s", paramIndex, sqlType, typeName); // fully qualified sql typeName is not supported by the driver and hence ignored. @@ -1007,8 +946,7 @@ public void registerOutParameter(int paramIndex, int sqlType, String typeName) @Override public void registerOutParameter(String paramName, int sqlType, int scale) throws SQLException { - LOG.finest("++enter++"); - LOG.finest( + LOG.finer( "registerOutParameter: paramIndex %s, sqlType %s, scale %s", paramName, sqlType, scale); checkClosed(); if (sqlType != Types.NUMERIC && sqlType != Types.DECIMAL) { @@ -1035,8 +973,7 @@ public void registerOutParameter(String paramName, int sqlType, int scale) throw @Override public void registerOutParameter(String paramName, int sqlType, String typeName) throws SQLException { - LOG.finest("++enter++"); - LOG.finest( + LOG.finer( "registerOutParameter: paramIndex %s, sqlType %s, typeName %s", paramName, sqlType, typeName); // fully qualified sql typeName is not supported by the driver and hence ignored. diff --git a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryConnection.java b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryConnection.java index 3c64e3a073f8..2792991b871f 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryConnection.java +++ b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryConnection.java @@ -151,8 +151,6 @@ public class BigQueryConnection extends BigQueryNoOpsConnection { BigQueryConnection(String url, DataSource ds) throws IOException { this.connectionId = UUID.randomUUID().toString(); try (BigQueryJdbcMdc.MdcCloseable mdc = BigQueryJdbcMdc.registerInstance(this.connectionId)) { - LOG.finest("++enter++"); - this.connectionUrl = url; this.openStatements = ConcurrentHashMap.newKeySet(); this.autoCommit = true; @@ -272,7 +270,7 @@ public class BigQueryConnection extends BigQueryNoOpsConnection { } String getLibraryVersion(Class libraryClass) { - LOG.finest("++enter++"); + LOG.finer("++enter++"); String version = null; try (InputStream in = libraryClass.getResourceAsStream( @@ -304,7 +302,7 @@ HeaderProvider createHeaderProvider() { } protected void addOpenStatements(Statement statement) { - LOG.finest("Statement %s added to Connection %s.", statement, this); + LOG.finer("Statement %s added to Connection %s.", statement, this); this.openStatements.add(statement); } @@ -350,7 +348,6 @@ String getConnectionId() { */ @Override public Statement createStatement() throws SQLException { - LOG.finest("++enter++"); checkClosed(); BigQueryStatement currentStatement = new BigQueryStatement(this); LOG.fine("Statement %s created.", currentStatement); @@ -374,7 +371,6 @@ public Statement createStatement() throws SQLException { @Override public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException { - LOG.finest("++enter++"); checkClosed(); if (resultSetType != ResultSet.TYPE_FORWARD_ONLY || resultSetConcurrency != ResultSet.CONCUR_READ_ONLY) { @@ -399,7 +395,6 @@ public Statement createStatement(int resultSetType, int resultSetConcurrency) @Override public Statement createStatement( int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { - LOG.finest("++enter++"); checkClosed(); if (resultSetType != ResultSet.TYPE_FORWARD_ONLY || resultSetConcurrency != ResultSet.CONCUR_READ_ONLY @@ -411,7 +406,6 @@ public Statement createStatement( @Override public PreparedStatement prepareStatement(String sql) throws SQLException { - LOG.finest("++enter++"); checkClosed(); PreparedStatement currentStatement = new BigQueryPreparedStatement(this, sql); LOG.fine("Prepared Statement %s created.", currentStatement); @@ -421,7 +415,6 @@ public PreparedStatement prepareStatement(String sql) throws SQLException { @Override public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException { - LOG.finest("++enter++"); if (autoGeneratedKeys != Statement.NO_GENERATED_KEYS) { throw new BigQueryJdbcSqlFeatureNotSupportedException("autoGeneratedKeys is not supported"); } @@ -437,7 +430,6 @@ public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throw public PreparedStatement prepareStatement( String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { - LOG.finest("++enter++"); if (resultSetType != ResultSet.TYPE_FORWARD_ONLY || resultSetConcurrency != ResultSet.CONCUR_READ_ONLY || resultSetHoldability != ResultSet.CLOSE_CURSORS_AT_COMMIT) { @@ -449,7 +441,6 @@ public PreparedStatement prepareStatement( @Override public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { - LOG.finest("++enter++"); if (resultSetType != ResultSet.TYPE_FORWARD_ONLY || resultSetConcurrency != ResultSet.CONCUR_READ_ONLY) { throw new BigQueryJdbcSqlFeatureNotSupportedException("Unsupported prepareStatement feature"); @@ -540,7 +531,7 @@ Map getLabels() { * href="https://cloud.google.com/bigquery/docs/transactions">Multi-statement transactions. */ private void beginTransaction() { - LOG.finest("++enter++"); + LOG.finer("++enter++"); QueryJobConfiguration.Builder transactionBeginJobConfig = QueryJobConfiguration.newBuilder("BEGIN TRANSACTION;"); try { @@ -668,14 +659,13 @@ Long getListenerPoolSize() { @Override public boolean isValid(int timeout) throws SQLException { - LOG.finest("++enter++"); if (timeout < 0) { throw new BigQueryJdbcException("timeout must be >= 0"); } if (!isClosed()) { try (Statement statement = createStatement(); ResultSet rs = statement.executeQuery("SELECT 1")) { - LOG.finest("Running validation query"); + LOG.finer("Running validation query"); if (rs.next()) { if (rs.getInt(1) == 1) { return true; @@ -690,7 +680,6 @@ public boolean isValid(int timeout) throws SQLException { @Override public void abort(Executor executor) throws SQLException { - LOG.finest("++enter++"); close(); } @@ -731,14 +720,12 @@ public void clearWarnings() { @Override public boolean getAutoCommit() { - LOG.finest("++enter++"); checkClosed(); return this.autoCommit; } @Override public void setAutoCommit(boolean autoCommit) throws SQLException { - LOG.finest("++enter++"); checkClosed(); checkIfEnabledSession("setAutoCommit"); if (this.autoCommit == autoCommit) { @@ -757,7 +744,6 @@ public void setAutoCommit(boolean autoCommit) throws SQLException { @Override public void commit() { - LOG.finest("++enter++"); checkClosed(); checkIfEnabledSession("commit"); if (!isTransactionStarted()) { @@ -776,7 +762,6 @@ public void commit() { @Override public void rollback() throws SQLException { - LOG.finest("++enter++"); checkClosed(); checkIfEnabledSession("rollback"); if (!isTransactionStarted()) { @@ -809,7 +794,6 @@ private void rollbackImpl() throws SQLException { @Override public DatabaseMetaData getMetaData() throws SQLException { - LOG.finest("++enter++"); if (databaseMetaData == null) { databaseMetaData = new BigQueryDatabaseMetaData(this); } @@ -823,7 +807,6 @@ public int getTransactionIsolation() { @Override public void setTransactionIsolation(int level) throws SQLException { - LOG.finest("++enter++"); if (level != Connection.TRANSACTION_SERIALIZABLE) { throw new BigQueryJdbcSqlFeatureNotSupportedException( "Unsupported transaction isolation level"); @@ -858,7 +841,6 @@ public void close() throws SQLException { return; } - LOG.finest("++enter++"); LOG.fine("Closing Connection " + this); closeImpl(); } @@ -918,7 +900,7 @@ private void checkIfEnabledSession(String methodName) { private ConnectionProperty getSessionPropertyFromQueryProperties( Map queryPropertiesMap) { - LOG.finest("++enter++"); + LOG.finer("++enter++"); if (queryPropertiesMap != null) { if (queryPropertiesMap.containsKey("session_id")) { return ConnectionProperty.newBuilder() @@ -932,7 +914,7 @@ private ConnectionProperty getSessionPropertyFromQueryProperties( private List convertMapToConnectionPropertiesList( Map queryPropertiesMap) { - LOG.finest("++enter++"); + LOG.finer("++enter++"); List connectionProperties = new ArrayList(); if (queryPropertiesMap != null) { for (Map.Entry entry : queryPropertiesMap.entrySet()) { @@ -1111,7 +1093,6 @@ public CallableStatement prepareCall(String sql) throws SQLException { @Override public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { - LOG.finest("++enter++"); checkClosed(); if (resultSetType != ResultSet.TYPE_FORWARD_ONLY || resultSetConcurrency != ResultSet.CONCUR_READ_ONLY) { @@ -1125,7 +1106,6 @@ public CallableStatement prepareCall(String sql, int resultSetType, int resultSe public CallableStatement prepareCall( String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { - LOG.finest("++enter++"); checkClosed(); if (resultSetType != ResultSet.TYPE_FORWARD_ONLY || resultSetConcurrency != ResultSet.CONCUR_READ_ONLY diff --git a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcBulkInsertWriter.java b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcBulkInsertWriter.java index d4e9702621dc..ea839c8bac0c 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcBulkInsertWriter.java +++ b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcBulkInsertWriter.java @@ -92,7 +92,7 @@ long cleanup(BigQueryWriteClient client) { // Finalize the stream. FinalizeWriteStreamResponse finalizeResponse = client.finalizeWriteStream(jsonStreamWriter.getStreamName()); - LOG.finest("Rows written: " + finalizeResponse.getRowCount()); + LOG.finer("Rows written: " + finalizeResponse.getRowCount()); return finalizeResponse.getRowCount(); } diff --git a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcContextProxy.java b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcContextProxy.java index c686e8070a76..ba02a99a3dcc 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcContextProxy.java +++ b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcContextProxy.java @@ -20,6 +20,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Proxy; +import java.util.logging.Level; /** * Dynamic InvocationHandler that transparently wraps JDBC operations. Sets the connection context @@ -130,8 +131,38 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl // Wrap execution in the context of the active connection for all non-bypassed methods try (BigQueryJdbcMdc.MdcCloseable mdc = BigQueryJdbcMdc.registerInstance(connectionId)) { + if (LOG.isLoggable(Level.FINER)) { + LOG.logp( + Level.FINER, + target.getClass().getName(), + method.getName(), + () -> + String.format( + "Entering: %s.%s(%s)", + interfaceType.getSimpleName(), + method.getName(), + args != null ? java.util.Arrays.toString(args) : "")); + } + Object result = method.invoke(target, args); + // Suppress exit logging for Connection.close() since its file handler is unmounted during + // execution + if (LOG.isLoggable(Level.FINER) + && !(java.sql.Connection.class.isAssignableFrom(interfaceType) + && "close".equals(method.getName()))) { + LOG.logp( + Level.FINER, + target.getClass().getName(), + method.getName(), + () -> + String.format( + "Exiting: %s.%s() -> %s", + interfaceType.getSimpleName(), + method.getName(), + result != null ? result.toString() : "null")); + } + // Symmetrical Cascade: Dynamic ResultSet concrete classes are deliberately unproxied here. // Bypassing proxies on high-frequency ResultSet iterations avoids dynamic invocation // and argument array allocations, allowing the JIT compiler to natively inline getters. @@ -157,7 +188,12 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl // context try (BigQueryJdbcMdc.MdcCloseable mdc = BigQueryJdbcMdc.registerInstance(connectionId)) { String errMsg = cause.getMessage() != null ? cause.getMessage() : cause.toString(); - LOG.severe("Exception occurred during " + method.getName() + ": " + errMsg, cause); + LOG.logp( + Level.SEVERE, + target.getClass().getName(), + method.getName(), + "Exception occurred during " + method.getName() + ": " + errMsg, + cause); } throw cause; diff --git a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcOAuthUtility.java b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcOAuthUtility.java index 7e05e7d74618..0b9166d4cda2 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcOAuthUtility.java +++ b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcOAuthUtility.java @@ -114,7 +114,7 @@ final class BigQueryJdbcOAuthUtility { * @return A map of OAuth properties. */ static Map parseOAuthProperties(DataSource ds, String callerClassName) { - LOG.finest("++enter++\t" + callerClassName); + LOG.finer("++enter++\t" + callerClassName); Map oauthProperties = new HashMap<>(); AuthType authType; @@ -263,7 +263,7 @@ static GoogleCredentials getCredentials( Map overrideProperties, Boolean reqGoogleDriveScopeBool, String callerClassName) { - LOG.finest("++enter++\t" + callerClassName); + LOG.finer("++enter++\t" + callerClassName); AuthType authType = AuthType.valueOf(authProperties.get(BigQueryJdbcUrlUtility.OAUTH_TYPE_PROPERTY_NAME)); @@ -327,7 +327,7 @@ private static GoogleCredentials getGoogleServiceAccountCredentials( Map authProperties, Map overrideProperties, String callerClassName) { - LOG.finest("++enter++\t" + callerClassName); + LOG.finer("++enter++\t" + callerClassName); ServiceAccountCredentials.Builder builder; try { @@ -393,7 +393,7 @@ static UserAuthorizer getUserAuthorizer( int port, String callerClassName) throws URISyntaxException { - LOG.finest("++enter++\t" + callerClassName); + LOG.finer("++enter++\t" + callerClassName); List scopes = new ArrayList<>(); scopes.add("https://www.googleapis.com/auth/bigquery"); @@ -421,7 +421,7 @@ static UserAuthorizer getUserAuthorizer( static UserCredentials getCredentialsFromCode( UserAuthorizer userAuthorizer, String code, String callerClassName) throws IOException { - LOG.finest("++enter++\t" + callerClassName); + LOG.finer("++enter++\t" + callerClassName); return userAuthorizer.getCredentialsFromCode(code, URI.create("")); } @@ -429,7 +429,7 @@ private static GoogleCredentials getGoogleUserAccountCredentials( Map authProperties, Map overrideProperties, String callerClassName) { - LOG.finest("++enter++\t" + callerClassName); + LOG.finer("++enter++\t" + callerClassName); try { ServerSocket serverSocket = new ServerSocket(0); serverSocket.setSoTimeout(USER_AUTH_TIMEOUT_MS); @@ -479,7 +479,7 @@ private static GoogleCredentials getPreGeneratedAccessTokenCredentials( Map authProperties, Map overrideProperties, String callerClassName) { - LOG.finest("++enter++\t" + callerClassName); + LOG.finer("++enter++\t" + callerClassName); GoogleCredentials.Builder builder = GoogleCredentials.newBuilder(); if (overrideProperties.containsKey( BigQueryJdbcUrlUtility.UNIVERSE_DOMAIN_OVERRIDE_PROPERTY_NAME)) { @@ -504,7 +504,7 @@ static GoogleCredentials getPreGeneratedTokensCredentials( Map authProperties, Map overrideProperties, String callerClassName) { - LOG.finest("++enter++\t" + callerClassName); + LOG.finer("++enter++\t" + callerClassName); if (authProperties.containsKey(BigQueryJdbcUrlUtility.OAUTH_REFRESH_TOKEN_PROPERTY_NAME)) { try { return getPreGeneratedRefreshTokenCredentials( @@ -524,7 +524,7 @@ static UserCredentials getPreGeneratedRefreshTokenCredentials( Map overrideProperties, String callerClassName) throws URISyntaxException { - LOG.finest("++enter++\t" + callerClassName); + LOG.finer("++enter++\t" + callerClassName); UserCredentials.Builder userCredentialsBuilder = UserCredentials.newBuilder() @@ -549,7 +549,7 @@ static UserCredentials getPreGeneratedRefreshTokenCredentials( } private static GoogleCredentials getApplicationDefaultCredentials(String callerClassName) { - LOG.finest("++enter++\t" + callerClassName); + LOG.finer("++enter++\t" + callerClassName); try { GoogleCredentials credentials = GoogleCredentials.getApplicationDefault(); String principal = "unknown"; @@ -573,7 +573,7 @@ private static GoogleCredentials getApplicationDefaultCredentials(String callerC private static GoogleCredentials getExternalAccountAuthCredentials( Map authProperties, String callerClassName) { - LOG.finest("++enter++\t" + callerClassName); + LOG.finer("++enter++\t" + callerClassName); try { JsonObject jsonObject = null; String credentialsPath = null; diff --git a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcResultSetLogger.java b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcResultSetLogger.java index f93300e60813..7b83af9805a8 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcResultSetLogger.java +++ b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcResultSetLogger.java @@ -56,6 +56,7 @@ public BigQueryJdbcResultSetLogger(Class clazz, String connectionId) { @Override public void log(LogRecord record) { + record.setThreadID((int) Thread.currentThread().getId()); if (connectionId != null) { Object[] existingParams = record.getParameters(); if (existingParams == null || existingParams.length == 0) { @@ -70,111 +71,169 @@ public void log(LogRecord record) { super.log(record); } + /** + * Log a message at Level.FINEST with predefined class name, method name and messageto avoid stack + * trace parsing on the hot-path. + */ + public void finestTrace(String methodName) { + if (isLoggable(Level.FINEST)) { + LogRecord record = new LogRecord(Level.FINEST, "++enter++"); + record.setSourceClassName(targetClassName); + record.setSourceMethodName(methodName); + this.log(record); + } + } + /** * Log a message at Level.FINEST with predefined class name and method name to avoid stack trace * parsing on the hot-path. */ public void finestTrace(String methodName, String msg) { if (isLoggable(Level.FINEST)) { - logp(Level.FINEST, targetClassName, methodName, msg); + LogRecord record = new LogRecord(Level.FINEST, msg); + record.setSourceClassName(targetClassName); + record.setSourceMethodName(methodName); + this.log(record); } } /** Log a formatted message at Level.FINEST with predefined class name and method name. */ public void finestTrace(String methodName, String format, Object... args) { if (isLoggable(Level.FINEST)) { - logp(Level.FINEST, targetClassName, methodName, String.format(format, args)); + LogRecord record = new LogRecord(Level.FINEST, String.format(format, args)); + record.setSourceClassName(targetClassName); + record.setSourceMethodName(methodName); + this.log(record); } } /** Log a lazy message at Level.FINEST with predefined class name and method name. */ public void finestTrace(String methodName, Supplier msgSupplier) { if (isLoggable(Level.FINEST)) { - logp(Level.FINEST, targetClassName, methodName, msgSupplier); + LogRecord record = new LogRecord(Level.FINEST, msgSupplier.get()); + record.setSourceClassName(targetClassName); + record.setSourceMethodName(methodName); + this.log(record); } } /** Log a message at Level.FINER with predefined class name and method name. */ public void finerTrace(String methodName, String msg) { if (isLoggable(Level.FINER)) { - logp(Level.FINER, targetClassName, methodName, msg); + LogRecord record = new LogRecord(Level.FINER, msg); + record.setSourceClassName(targetClassName); + record.setSourceMethodName(methodName); + this.log(record); } } /** Log a formatted message at Level.FINER with predefined class name and method name. */ public void finerTrace(String methodName, String format, Object... args) { if (isLoggable(Level.FINER)) { - logp(Level.FINER, targetClassName, methodName, String.format(format, args)); + LogRecord record = new LogRecord(Level.FINER, String.format(format, args)); + record.setSourceClassName(targetClassName); + record.setSourceMethodName(methodName); + this.log(record); } } /** Log a lazy message at Level.FINER with predefined class name and method name. */ public void finerTrace(String methodName, Supplier msgSupplier) { if (isLoggable(Level.FINER)) { - logp(Level.FINER, targetClassName, methodName, msgSupplier); + LogRecord record = new LogRecord(Level.FINER, msgSupplier.get()); + record.setSourceClassName(targetClassName); + record.setSourceMethodName(methodName); + this.log(record); } } /** Log a message at Level.FINE with predefined class name and method name. */ public void fineTrace(String methodName, String msg) { if (isLoggable(Level.FINE)) { - logp(Level.FINE, targetClassName, methodName, msg); + LogRecord record = new LogRecord(Level.FINE, msg); + record.setSourceClassName(targetClassName); + record.setSourceMethodName(methodName); + this.log(record); } } /** Log a formatted message at Level.FINE with predefined class name and method name. */ public void fineTrace(String methodName, String format, Object... args) { if (isLoggable(Level.FINE)) { - logp(Level.FINE, targetClassName, methodName, String.format(format, args)); + LogRecord record = new LogRecord(Level.FINE, String.format(format, args)); + record.setSourceClassName(targetClassName); + record.setSourceMethodName(methodName); + this.log(record); } } /** Log a lazy message at Level.FINE with predefined class name and method name. */ public void fineTrace(String methodName, Supplier msgSupplier) { if (isLoggable(Level.FINE)) { - logp(Level.FINE, targetClassName, methodName, msgSupplier); + LogRecord record = new LogRecord(Level.FINE, msgSupplier.get()); + record.setSourceClassName(targetClassName); + record.setSourceMethodName(methodName); + this.log(record); } } @Override public void finest(String msg) { if (isLoggable(Level.FINEST)) { - logp(Level.FINEST, targetClassName, "unknown", msg); + LogRecord record = new LogRecord(Level.FINEST, msg); + record.setSourceClassName(targetClassName); + record.setSourceMethodName("unknown"); + this.log(record); } } @Override public void finest(Supplier msgSupplier) { if (isLoggable(Level.FINEST)) { - logp(Level.FINEST, targetClassName, "unknown", msgSupplier); + LogRecord record = new LogRecord(Level.FINEST, msgSupplier.get()); + record.setSourceClassName(targetClassName); + record.setSourceMethodName("unknown"); + this.log(record); } } @Override public void finer(String msg) { if (isLoggable(Level.FINER)) { - logp(Level.FINER, targetClassName, "unknown", msg); + LogRecord record = new LogRecord(Level.FINER, msg); + record.setSourceClassName(targetClassName); + record.setSourceMethodName("unknown"); + this.log(record); } } @Override public void finer(Supplier msgSupplier) { if (isLoggable(Level.FINER)) { - logp(Level.FINER, targetClassName, "unknown", msgSupplier); + LogRecord record = new LogRecord(Level.FINER, msgSupplier.get()); + record.setSourceClassName(targetClassName); + record.setSourceMethodName("unknown"); + this.log(record); } } @Override public void fine(String msg) { if (isLoggable(Level.FINE)) { - logp(Level.FINE, targetClassName, "unknown", msg); + LogRecord record = new LogRecord(Level.FINE, msg); + record.setSourceClassName(targetClassName); + record.setSourceMethodName("unknown"); + this.log(record); } } @Override public void fine(Supplier msgSupplier) { if (isLoggable(Level.FINE)) { - logp(Level.FINE, targetClassName, "unknown", msgSupplier); + LogRecord record = new LogRecord(Level.FINE, msgSupplier.get()); + record.setSourceClassName(targetClassName); + record.setSourceMethodName("unknown"); + this.log(record); } } } diff --git a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcRootLogger.java b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcRootLogger.java index 06edb21c28bd..fae958b1b9ef 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcRootLogger.java +++ b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcRootLogger.java @@ -104,7 +104,10 @@ public String format(LogRecord record) { threadName = threadName.substring(threadName.length() - MAX_THREAD_NAME_LENGTH); } - String sourceClassName = record.getLoggerName(); + String sourceClassName = + record.getSourceClassName() != null + ? record.getSourceClassName() + : record.getLoggerName(); String sourceMethodName = record.getSourceMethodName(); // Expected log format: yyyy-MM-dd HH:mm:ss.SSS [CONNECTION_ID] LEVEL PID --- [THREAD] CLASS diff --git a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJsonArray.java b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJsonArray.java index bc59192b84d7..582139a0d27e 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJsonArray.java +++ b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJsonArray.java @@ -44,7 +44,7 @@ class BigQueryJsonArray extends BigQueryBaseArray { @Override public Object getArray() { ensureValid(); - LOG.finestTrace("getArray", "++enter++"); + LOG.finestTrace("getArray"); if (this.values == null) { return null; } @@ -54,7 +54,7 @@ public Object getArray() { @Override public Object getArray(long index, int count) { ensureValid(); - LOG.finestTrace("getArray", "++enter++"); + LOG.finestTrace("getArray"); if (this.values == null) { return null; } @@ -65,7 +65,7 @@ public Object getArray(long index, int count) { @Override public ResultSet getResultSet() { ensureValid(); - LOG.finestTrace("getResultSet", "++enter++"); + LOG.finestTrace("getResultSet"); if (this.values == null) { return new BigQueryJsonResultSet(); } @@ -78,7 +78,7 @@ public ResultSet getResultSet() { @Override public ResultSet getResultSet(long index, int count) { ensureValid(); - LOG.finestTrace("getResultSet", "++enter++"); + LOG.finestTrace("getResultSet"); if (this.values == null) { return new BigQueryJsonResultSet(); } diff --git a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJsonResultSet.java b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJsonResultSet.java index e2d99c34e6ca..8c07e0d3018a 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJsonResultSet.java +++ b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJsonResultSet.java @@ -185,7 +185,7 @@ public boolean next() throws SQLException { public Object getObject(int columnIndex) throws SQLException { // columnIndex is SQL index starting at 1 checkClosed(); - LOG.finestTrace("getObject", "++enter++"); + LOG.finestTrace("getObject"); FieldValue value = getObjectInternal(columnIndex); if (value == null || value.isNull()) { return null; @@ -230,7 +230,7 @@ public Object getObject(int columnIndex) throws SQLException { */ private FieldValue getObjectInternal(int columnIndex) throws SQLException { checkClosed(); - LOG.finestTrace("getObjectInternal", "++enter++"); + LOG.finestTrace("getObjectInternal"); FieldValue value; if (this.isNested) { boolean validIndexForNestedResultSet = columnIndex == 1 || columnIndex == 2; @@ -287,7 +287,7 @@ public void close() { @Override public boolean isBeforeFirst() throws SQLException { checkClosed(); - LOG.finestTrace("isBeforeFirst", "++enter++"); + LOG.finestTrace("isBeforeFirst"); if (this.isNested) { return this.nestedRowIndex < this.fromIndex; } else { @@ -298,14 +298,14 @@ public boolean isBeforeFirst() throws SQLException { @Override public boolean isAfterLast() throws SQLException { checkClosed(); - LOG.finestTrace("isAfterLast", "++enter++"); + LOG.finestTrace("isAfterLast"); return this.afterLast; } @Override public boolean isFirst() throws SQLException { checkClosed(); - LOG.finestTrace("isFirst", "++enter++"); + LOG.finestTrace("isFirst"); if (this.isNested) { return this.nestedRowIndex == this.fromIndex; } else { @@ -316,7 +316,7 @@ public boolean isFirst() throws SQLException { @Override public boolean isLast() throws SQLException { checkClosed(); - LOG.finestTrace("isLast", "++enter++"); + LOG.finestTrace("isLast"); if (this.isNested) { return this.nestedRowIndex == this.toIndexExclusive - 1; } else { diff --git a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJsonStruct.java b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJsonStruct.java index 504db6a1e097..9c3814287fd7 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJsonStruct.java +++ b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJsonStruct.java @@ -51,7 +51,7 @@ FieldList getSchema() { @Override public Object[] getAttributes() { - LOG.finestTrace("getAttributes", "++enter++"); + LOG.finestTrace("getAttributes"); int size = schema.size(); Object[] attributes = (Object[]) Array.newInstance(Object.class, size); @@ -65,7 +65,7 @@ public Object[] getAttributes() { } private Object getValue(Field currentSchema, FieldValue currentValue) { - LOG.finestTrace("getValue", "++enter++"); + LOG.finestTrace("getValue"); if (isArray(currentSchema)) { return new BigQueryJsonArray(currentSchema, currentValue); } else if (isStruct(currentSchema)) { diff --git a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryPreparedStatement.java b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryPreparedStatement.java index f02227e0edc3..a42cbd2a1545 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryPreparedStatement.java +++ b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryPreparedStatement.java @@ -84,13 +84,12 @@ void setCurrentQuery(String currentQuery) { } private int getParameterCount(String query) { - LOG.finest("++enter++"); + LOG.finer("++enter++"); return (int) query.chars().filter(ch -> ch == POSITIONAL_PARAMETER_CHAR).count(); } @Override public ResultSet executeQuery() throws SQLException { - LOG.finest("++enter++"); logQueryExecutionStart(this.currentQuery); try { QueryJobConfiguration.Builder jobConfiguration = getJobConfig(this.currentQuery); @@ -105,7 +104,6 @@ public ResultSet executeQuery() throws SQLException { @Override public long executeLargeUpdate() throws SQLException { - LOG.finest("++enter++"); logQueryExecutionStart(this.currentQuery); try { QueryJobConfiguration.Builder jobConfiguration = getJobConfig(this.currentQuery); @@ -120,13 +118,11 @@ public long executeLargeUpdate() throws SQLException { @Override public int executeUpdate() throws SQLException { - LOG.finest("++enter++"); return checkUpdateCount(executeLargeUpdate()); } @Override public boolean execute() throws SQLException { - LOG.finest("++enter++"); logQueryExecutionStart(this.currentQuery); try { QueryJobConfiguration.Builder jobConfiguration = getJobConfig(this.currentQuery); @@ -141,7 +137,6 @@ public boolean execute() throws SQLException { @Override public void clearParameters() { - LOG.finest("++enter++"); this.parameterHandler.clearParameters(); this.parameterCount = 0; } @@ -254,7 +249,6 @@ public void setObject(int parameterIndex, Object x) { @Override public void addBatch() { - LOG.finest("++enter++"); ArrayList currentParameterList = deepCopyParameterList(this.parameterHandler.parametersList); this.batchParameters.add(currentParameterList); @@ -272,7 +266,6 @@ private ArrayList deepCopyParameterList( @Override public int[] executeBatch() throws SQLException { - LOG.finest("++enter++"); int[] result = new int[this.batchParameters.size()]; if (this.batchParameters.isEmpty()) { return result; @@ -333,7 +326,7 @@ private long bulkInsertWithWriteAPI(BigQueryWriteClient bigQueryWriteClient) IOException, InterruptedException, BigQueryJdbcException { - LOG.finest("++enter++"); + LOG.finer("++enter++"); RetrySettings retrySettings = this.connection.getRetrySettings(); BigQueryJdbcBulkInsertWriter bulkInsertWriter = new BigQueryJdbcBulkInsertWriter(); @@ -364,7 +357,7 @@ private long bulkInsertWithWriteAPI(BigQueryWriteClient bigQueryWriteClient) if (jsonArray.size() == this.querySettings.getWriteAPIAppendRowCount() || this.batchParameters.size() == 0) { bulkInsertWriter.append(jsonArray, offset); - LOG.finest("Append called "); + LOG.finer("Append called "); offset += jsonArray.size(); jsonArray = new JsonArray(); } @@ -388,12 +381,12 @@ private long bulkInsertWithWriteAPI(BigQueryWriteClient bigQueryWriteClient) if (commitResponse.hasCommitTime() == false) { throw new BigQueryJdbcException("Error committing the streams"); } - LOG.finest("Commit called."); + LOG.finer("Commit called."); return rowCount; } private void setInsertMetadata(QueryStatistics statistics) throws SQLException { - LOG.finest("++enter++"); + LOG.finer("++enter++"); if (!statistics.getStatementType().equals(StatementType.INSERT) || statistics.getSchema() == null || statistics.getReferencedTables().stream().distinct().count() > 1) { @@ -405,14 +398,14 @@ private void setInsertMetadata(QueryStatistics statistics) throws SQLException { TableId tableID = statistics.getReferencedTables().get(0); this.insertTableName = TableName.of(tableID.getProject(), tableID.getDataset(), tableID.getTable()); - LOG.finest( + LOG.finer( "this.insertTableName : %s, this.insertSchema : %s", this.insertTableName, this.insertSchema.toString()); } QueryJobConfiguration getWriteBatchJobConfiguration( ArrayList currentParameterList) throws SQLException { - LOG.finest("++enter++"); + LOG.finer("++enter++"); BigQueryParameterHandler batchHandler = new BigQueryParameterHandler(this.parameterCount, currentParameterList); QueryJobConfiguration.Builder jobConfiguration = getJobConfig(this.currentQuery); @@ -422,7 +415,7 @@ QueryJobConfiguration getWriteBatchJobConfiguration( } QueryJobConfiguration getStandardBatchJobConfiguration(String query) throws SQLException { - LOG.finest("++enter++"); + LOG.finer("++enter++"); QueryJobConfiguration.Builder jobConfiguration = getJobConfig(query); jobConfiguration.setParameterMode("POSITIONAL"); jobConfiguration.setPriority(QueryJobConfiguration.Priority.BATCH); @@ -433,7 +426,7 @@ QueryJobConfiguration getStandardBatchJobConfiguration(String query) throws SQLE for (BigQueryJdbcParameter parameter : parameterList) { Object parameterValue = parameter.getValue(); StandardSQLTypeName sqlType = parameter.getSqlType(); - LOG.finest( + LOG.finer( "Parameter %s of type %s at index %s added to QueryJobConfiguration", parameterValue, sqlType, index++); jobConfiguration.addPositionalParameter(QueryParameterValue.of(parameterValue, sqlType)); @@ -443,7 +436,7 @@ QueryJobConfiguration getStandardBatchJobConfiguration(String query) throws SQLE } Boolean useWriteAPI() { - LOG.finest("++enter++"); + LOG.finer("++enter++"); if (this.querySettings.isUseWriteAPI()) { if (this.batchParameters.size() >= this.querySettings.getWriteAPIActivationRowCount()) { return true; diff --git a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryResultSetFinalizers.java b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryResultSetFinalizers.java index 97e04d858380..85a00214376f 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryResultSetFinalizers.java +++ b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryResultSetFinalizers.java @@ -39,7 +39,7 @@ public ArrowResultSetFinalizer( // Free resources. Remove all the hard refs public void finalizeResources() { - LOG.finestTrace("finalizeResources", "++enter++"); + LOG.finestTrace("finalizeResources"); if (ownedThread != null && !ownedThread.isInterrupted()) { ownedThread.interrupt(); } @@ -60,7 +60,7 @@ public JsonResultSetFinalizer( // Free resources. Remove all the hard refs public void finalizeResources() { - LOG.finestTrace("finalizeResources", "++enter++"); + LOG.finestTrace("finalizeResources"); if (ownedThreads != null) { for (Thread ownedThread : ownedThreads) { if (!ownedThread.isInterrupted()) { diff --git a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryResultSetMetadata.java b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryResultSetMetadata.java index fc71394803b4..976e91b46aa4 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryResultSetMetadata.java +++ b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryResultSetMetadata.java @@ -37,7 +37,7 @@ class BigQueryResultSetMetadata implements ResultSetMetaData { private static final int DEFAULT_DISPLAY_SIZE = 50; private BigQueryResultSetMetadata(FieldList schemaFieldList, Statement statement) { - LOG.finestTrace("", "++enter++"); + LOG.finestTrace(""); this.schemaFieldList = schemaFieldList; this.columnCount = schemaFieldList.size(); this.statement = statement; diff --git a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryStatement.java b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryStatement.java index e2dab7b31678..36081a6354e0 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryStatement.java +++ b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryStatement.java @@ -164,7 +164,6 @@ private void resetStatementFields() { } private BigQuerySettings generateBigQuerySettings() { - LOG.finest("++enter++"); BigQuerySettings.Builder querySettings = BigQuerySettings.newBuilder(); DatasetId defaultDataset = this.connection.getDefaultDataset(); @@ -235,7 +234,6 @@ private BigQuerySettings generateBigQuerySettings() { */ @Override public ResultSet executeQuery(String sql) throws SQLException { - LOG.finest("++enter++"); checkClosed(); return executeQueryImpl(sql); } @@ -259,7 +257,6 @@ private ResultSet executeQueryImpl(String sql) throws SQLException { @Override public long executeLargeUpdate(String sql) throws SQLException { - LOG.finest("++enter++"); checkClosed(); return executeLargeUpdateImpl(sql); } @@ -281,12 +278,10 @@ private long executeLargeUpdateImpl(String sql) throws SQLException { @Override public int executeUpdate(String sql) throws SQLException { - LOG.finest("++enter++"); return checkUpdateCount(executeLargeUpdate(sql)); } int checkUpdateCount(long updateCount) { - LOG.finest("++enter++"); if (updateCount > Integer.MAX_VALUE) { LOG.warning("Warning: Table update exceeded maximum limit!"); // Update count is -2 if update is successful but the update count exceeds Integer.MAX_VALUE @@ -297,7 +292,6 @@ int checkUpdateCount(long updateCount) { @Override public boolean execute(String sql) throws SQLException { - LOG.finest("++enter++"); checkClosed(); return executeImpl(sql); } @@ -318,7 +312,6 @@ private boolean executeImpl(String sql) throws SQLException { } StatementType getStatementType(QueryJobConfiguration queryJobConfiguration) throws SQLException { - LOG.finest("++enter++"); // BQ Read-only tokens are not recommended to use, they have a lot of known flaws. // We're supporting them in a limited capacity, for pure SELECT statements. if (this.connection.isReadOnlyTokenUsed()) { @@ -344,7 +337,7 @@ StatementType getStatementType(QueryJobConfiguration queryJobConfiguration) thro SqlType getQueryType(QueryJobConfiguration jobConfiguration, StatementType statementType) throws SQLException { - LOG.finest("++enter++"); + LOG.finer("++enter++"); if (statementType == null) { statementType = getStatementType(jobConfiguration); } @@ -358,7 +351,7 @@ SqlType getQueryType(QueryJobConfiguration jobConfiguration, StatementType state QueryStatistics getQueryStatistics(QueryJobConfiguration queryJobConfiguration) throws BigQueryJdbcSqlSyntaxErrorException, BigQueryJdbcException { - LOG.finest("++enter++"); + LOG.finer("++enter++"); QueryJobConfiguration dryRunJobConfiguration = queryJobConfiguration.toBuilder().setDryRun(true).build(); Job job; @@ -453,7 +446,7 @@ public void setQueryTimeout(int seconds) { */ @Override public void cancel() throws SQLException { - LOG.finest("Statement %s cancelled", this); + LOG.finer("Statement %s cancelled", this); synchronized (cancelLock) { this.isCanceled = true; for (JobId jobId : this.jobIds) { @@ -513,7 +506,7 @@ public boolean getMoreResults() throws SQLException { } private void closeStatementResources() throws SQLException { - LOG.finest("++enter++"); + LOG.finer("++enter++"); if (this.currentResultSet != null) { // If Statement has 'CloseOnCompletion' set, resultset might // call into the same function; In order to avoid stack overflow @@ -555,7 +548,7 @@ private class ExecuteResult { @InternalApi ExecuteResult executeJob(QueryJobConfiguration jobConfiguration) throws InterruptedException, BigQueryException, BigQueryJdbcException { - LOG.finest("++enter++"); + LOG.finer("++enter++"); Job job = null; // Location is not properly passed from the connection, // so we need to explicitly set it; @@ -600,7 +593,7 @@ ExecuteResult executeJob(QueryJobConfiguration jobConfiguration) @InternalApi void runQuery(String query, QueryJobConfiguration jobConfiguration) throws SQLException, InterruptedException { - LOG.finest("++enter++"); + LOG.finer("++enter++"); LOG.fine("Run Query started"); if (queryTimeout > 0) { @@ -680,7 +673,7 @@ Job getNextJob() { void handleQueryResult(String query, TableResult results, SqlType queryType) throws SQLException, InterruptedException { - LOG.finest("++enter++"); + LOG.finer("++enter++"); switch (queryType) { case SELECT: processQueryResponse(query, results); @@ -755,7 +748,7 @@ BigQueryReadClient getBigQueryReadClient() { @InternalApi ReadSession getReadSession(CreateReadSessionRequest readSessionRequest) { - LOG.finest("++enter++"); + LOG.finer("++enter++"); return getBigQueryReadClient().createReadSession(readSessionRequest); } @@ -767,7 +760,7 @@ ArrowSchema getArrowSchema(ReadSession readSession) { /** Uses Bigquery Storage Read API and returns the stream as ResultSet */ @InternalApi ResultSet processArrowResultSet(TableResult results) throws SQLException { - LOG.finest("++enter++"); + LOG.finer("++enter++"); // set the resultset long totalRows = (getMaxRows() > 0) ? getMaxRows() : results.getTotalRows(); @@ -827,7 +820,7 @@ Thread populateArrowBufferedQueue( ReadSession readSession, BlockingQueue arrowBatchWrapperBlockingQueue, BigQueryReadClient bqReadClient) { - LOG.finest("++enter++"); + LOG.finer("++enter++"); Runnable arrowStreamProcessor = () -> { @@ -892,11 +885,21 @@ Thread populateArrowBufferedQueue( enqueueError(arrowBatchWrapperBlockingQueue, e); Thread.currentThread().interrupt(); } catch (Exception e) { - LOG.log( - Level.WARNING, - "\n" + Thread.currentThread().getName() + " Error @ arrowStreamProcessor", - e); - enqueueError(arrowBatchWrapperBlockingQueue, e); + if (e.getCause() instanceof InterruptedException + || Thread.currentThread().isInterrupted()) { + LOG.log( + Level.WARNING, + "\n" + Thread.currentThread().getName() + " Interrupted @ arrowStreamProcessor", + e); + enqueueError(arrowBatchWrapperBlockingQueue, e); + Thread.currentThread().interrupt(); + } else { + LOG.log( + Level.WARNING, + "\n" + Thread.currentThread().getName() + " Error @ arrowStreamProcessor", + e); + enqueueError(arrowBatchWrapperBlockingQueue, e); + } } finally { // logic needed for graceful shutdown enqueueEndOfStream(arrowBatchWrapperBlockingQueue); } @@ -909,7 +912,7 @@ Thread populateArrowBufferedQueue( /** Executes SQL query using either fast query path or read API */ void processQueryResponse(String query, TableResult results) throws SQLException { - LOG.finest( + LOG.finer( "API call completed{Query=%s, Parent Job ID=%s, Total rows=%s} ", query, results.getJobId(), results.getTotalRows()); JobId currentJobId = results.getJobId(); @@ -932,7 +935,7 @@ void processQueryResponse(String query, TableResult results) throws SQLException // AND the User must not have disabled the Read API @VisibleForTesting boolean useReadAPI(TableResult results) throws BigQueryJdbcSqlFeatureNotSupportedException { - LOG.finest("++enter++"); + LOG.finer("++enter++"); if (!meetsReadRatio(results)) { return false; } @@ -941,7 +944,7 @@ boolean useReadAPI(TableResult results) throws BigQueryJdbcSqlFeatureNotSupporte } private boolean meetsReadRatio(TableResult results) { - LOG.finest("++enter++"); + LOG.finer("++enter++"); long totalRows = results.getTotalRows(); if (totalRows == 0 || totalRows < querySettings.getHighThroughputMinTableSize()) { @@ -1016,7 +1019,7 @@ BigQueryJsonResultSet processJsonResultSet(TableResult results) { void populateFirstPage( TableResult result, BlockingQueue> rpcResponseQueue) { - LOG.finest("++enter++"); + LOG.finer("++enter++"); // parse and put the first page in the pageCache before the other pages are parsed from the RPC // calls try { @@ -1044,7 +1047,7 @@ Thread runNextPageTaskAsync( JobId jobId, BlockingQueue> rpcResponseQueue, BlockingQueue bigQueryFieldValueListWrapperBlockingQueue) { - LOG.finest("++enter++"); + LOG.finer("++enter++"); // parse and put the first page in the pageCache before the other pages are parsed from the RPC // calls populateFirstPage(result, rpcResponseQueue); @@ -1111,7 +1114,7 @@ Thread parseAndPopulateRpcDataAsync( Schema schema, BlockingQueue bigQueryFieldValueListWrapperBlockingQueue, BlockingQueue> rpcResponseQueue) { - LOG.finest("++enter++"); + LOG.finer("++enter++"); Runnable populateBufferRunnable = () -> { // producer thread populating the buffer @@ -1162,11 +1165,21 @@ Thread parseAndPopulateRpcDataAsync( } } catch (Exception ex) { - LOG.log( - Level.WARNING, - "\n" + Thread.currentThread().getName() + " Error @ populateBufferAsync", - ex); - enqueueBufferError(bigQueryFieldValueListWrapperBlockingQueue, ex); + if (ex.getCause() instanceof InterruptedException + || Thread.currentThread().isInterrupted()) { + LOG.log( + Level.WARNING, + "\n" + Thread.currentThread().getName() + " Interrupted @ populateBufferAsync", + ex); + enqueueBufferError(bigQueryFieldValueListWrapperBlockingQueue, ex); + Thread.currentThread().interrupt(); + } else { + LOG.log( + Level.WARNING, + "\n" + Thread.currentThread().getName() + " Error @ populateBufferAsync", + ex); + enqueueBufferError(bigQueryFieldValueListWrapperBlockingQueue, ex); + } } finally { enqueueBufferEndOfStream(bigQueryFieldValueListWrapperBlockingQueue); } @@ -1182,7 +1195,7 @@ Thread parseAndPopulateRpcDataAsync( */ @VisibleForTesting int getPageCacheSize(Integer numBufferedRows, Schema schema) { - LOG.finest("++enter++"); + LOG.finer("++enter++"); // Min number of pages to cache final int MIN_CACHE_SIZE = 3; // Min number of pages to cache @@ -1233,12 +1246,12 @@ private int getBufferSize() { /** Returns the destinationTable from jobId by calling `jobs.get` API */ TableId getDestinationTable(JobId jobId) { Job job = this.bigQuery.getJob(jobId); - LOG.finest("Destination Table retrieved from %s", job.getJobId()); + LOG.finer("Destination Table retrieved from %s", job.getJobId()); return ((QueryJobConfiguration) job.getConfiguration()).getDestinationTable(); } QueryJobConfiguration.Builder getJobConfig(String query) { - LOG.finest("++enter++"); + LOG.finer("++enter++"); QueryJobConfiguration.Builder queryConfigBuilder = QueryJobConfiguration.newBuilder(query); if (this.querySettings.getJobTimeoutMs() > 0) { queryConfigBuilder.setJobTimeoutMs(this.querySettings.getJobTimeoutMs()); @@ -1303,9 +1316,9 @@ private String getDefaultDestinationTable() { @InternalApi JobIdWrapper insertJob(JobConfiguration jobConfiguration) throws SQLException { + LOG.finer("++enter++"); Job job; JobInfo jobInfo = JobInfo.of(jobConfiguration); - LOG.finest("++enter++"); try { job = this.bigQuery.create(jobInfo); } catch (BigQueryException ex) { @@ -1402,7 +1415,6 @@ public void addBatch(String sql) throws SQLException { if (sql == null || sql.isEmpty()) { return; } - LOG.finest("++enter++"); sql = sql.trim(); if (!sql.endsWith(";")) { sql += "; "; @@ -1424,7 +1436,6 @@ public void clearBatch() { @Override public int[] executeBatch() throws SQLException { - LOG.finest("++enter++"); int[] result = new int[this.batchQueries.size()]; if (this.batchQueries.isEmpty()) { return result; @@ -1464,7 +1475,6 @@ public boolean hasMoreResults() { @Override public boolean getMoreResults(int current) throws SQLException { - LOG.finest("++enter++"); checkClosed(); return getMoreResultsImpl(current); } diff --git a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryThreadFactory.java b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryThreadFactory.java index bba57d731146..6ca2e69036ef 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryThreadFactory.java +++ b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryThreadFactory.java @@ -18,6 +18,8 @@ import com.google.api.core.InternalApi; import java.util.concurrent.ThreadFactory; +import java.util.logging.Level; +import java.util.logging.LogRecord; @InternalApi class BigQueryThreadFactory implements ThreadFactory { @@ -38,7 +40,14 @@ public BigQueryThreadFactory() { public Thread newThread(Runnable r) { Thread t = new Thread(r, threadPrefix + (++threadSerialNum)); // non thread safe increment t.setDaemon(true); - LOG.finest("New thread %s created.", t.getName()); + if (LOG.isLoggable(Level.FINER)) { + LogRecord record = + new LogRecord(Level.FINER, String.format("New thread %s created.", t.getName())); + record.setSourceClassName(BigQueryThreadFactory.class.getName()); + record.setSourceMethodName("newThread"); + record.setThreadID((int) t.getId()); + LOG.log(record); + } return t; } }