diff src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java @ 286:d430f8adbf1b

Add keyword "final" to those variables which do not change after first assigment. In MonetConnection.java corrected size of array (was 7): isSet = new boolean[4]; In MonetPreparedStatement.java removed variable connection as it is already present in superclass MonetStatement (changed it into protected). In MonetResultSet.java sinplified code for assigning Connection conn and DatabaseMetaData dbmd. It is now done on instantiation. This allows them to become "final".
author Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
date Thu, 25 Jul 2019 19:04:10 +0200 (2019-07-25)
parents 637899bda602
children 2ad7f42f141d f412032e3b43
line wrap: on
line diff
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java
@@ -1933,13 +1933,11 @@ public class MonetConnection
 		/** A List of result blocks (chunks of size fetchSize/cacheSize) */
 		private DataBlockResponse[] resultBlocks;
 
-		/** A bitmap telling whether the headers are set or not */
-		private boolean[] isSet;
 		/** Whether this Response is closed */
 		private boolean closed;
 
 		/** The Connection that we should use when requesting a new block */
-		private MonetConnection.ResponseList parent;
+		private final MonetConnection.ResponseList parent;
 		/** Whether the fetchSize was explitly set by the user */
 		private boolean cacheSizeSetExplicitly = false;
 		/** Whether we should send an Xclose command to the server
@@ -1951,6 +1949,8 @@ public class MonetConnection
 		/** A parser for header lines */
 		HeaderLineParser hlp;
 
+		/** A boolean array telling whether the headers are set or not */
+		private final boolean[] isSet;
 		private static final int NAMES	= 0;
 		private static final int TYPES	= 1;
 		private static final int TABLES	= 2;
@@ -1978,7 +1978,7 @@ public class MonetConnection
 				int seq)
 			throws SQLException
 		{
-			isSet = new boolean[7];
+			isSet = new boolean[4];
 			this.parent = parent;
 			if (parent.cachesize == 0) {
 				/* Below we have to calculate how many "chunks" we need
@@ -2008,15 +2008,11 @@ public class MonetConnection
 			this.id = id;
 			this.tuplecount = tuplecount;
 			this.columncount = columncount;
-			this.resultBlocks =
-				new DataBlockResponse[(tuplecount / cacheSize) + 1];
+			this.resultBlocks = new DataBlockResponse[(tuplecount / cacheSize) + 1];
 
 			hlp = new HeaderLineParser(columncount);
 
-			resultBlocks[0] = new DataBlockResponse(
-				rowcount,
-				parent.rstype == ResultSet.TYPE_FORWARD_ONLY
-			);
+			resultBlocks[0] = new DataBlockResponse(rowcount, parent.rstype == ResultSet.TYPE_FORWARD_ONLY);
 		}
 
 		/**