db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r358137 - in /db/derby/code/branches/10.1/java: engine/org/apache/derby/impl/load/ tools/org/apache/derby/iapi/tools/i18n/
Date Tue, 20 Dec 2005 23:04:43 GMT
Author: djd
Date: Tue Dec 20 15:04:37 2005
New Revision: 358137

URL: http://svn.apache.org/viewcvs?rev=358137&view=rev
Log:
DERBY-777 Remove use of java.io.InputStreamReader.getEncoding to get the
platform's default encoding. Creating this reader on System.in was causing
a hang on Z/OS.
Now simply use the stream/reader constructors that do not take a encoding
argument and thus use the default. With this Derby does not need to know
the actual value of default encoding.

Modified:
    db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/load/ControlInfo.java
    db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/load/ExportWriteData.java
    db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/load/ImportReadData.java
    db/derby/code/branches/10.1/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedInput.java
    db/derby/code/branches/10.1/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedOutput.java
    db/derby/code/branches/10.1/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedResource.java

Modified: db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/load/ControlInfo.java
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/load/ControlInfo.java?rev=358137&r1=358136&r2=358137&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/load/ControlInfo.java (original)
+++ db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/load/ControlInfo.java Tue
Dec 20 15:04:37 2005
@@ -118,10 +118,6 @@
     currentProperties.put(FIELD_START_DELIMITER, DEFAULT_FIELD_START_DELIMITER);
     currentProperties.put(FIELD_END_DELIMITER, DEFAULT_FIELD_END_DELIMITER);
     currentProperties.put(VERSION, DEFAULT_VERSION);
-    // set the default code set to the platform default encoding value
-    String default_data_codeset =
-                          (new InputStreamReader(System.in)).getEncoding();
-    currentProperties.put(DATA_CODESET, default_data_codeset);
     currentProperties.put(HAS_DELIMETER_AT_END, INTERNAL_FALSE);
   }
 
@@ -254,6 +250,11 @@
     return aDelimiter;
   }
 
+  /**
+   * 
+   * @return Code set, can return null for use the default code set.
+   * @throws Exception
+   */
   String getDataCodeset() throws Exception {
     return(getCurrentProperties().getProperty(DATA_CODESET));
   }

Modified: db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/load/ExportWriteData.java
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/load/ExportWriteData.java?rev=358137&r1=358136&r2=358137&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/load/ExportWriteData.java
(original)
+++ db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/load/ExportWriteData.java
Tue Dec 20 15:04:37 2005
@@ -67,7 +67,11 @@
       outputFileName = url.getFile();
     } catch (MalformedURLException ex) {}
     FileOutputStream anOutputStream = new FileOutputStream(outputFileName);
-    aStream = new OutputStreamWriter(new BufferedOutputStream(anOutputStream), dataCodeset);
+    BufferedOutputStream buffered = new BufferedOutputStream(anOutputStream);
+    
+    aStream = dataCodeset == null ?
+    		new OutputStreamWriter(buffered) :
+    		new OutputStreamWriter(buffered, dataCodeset);    	        
   }
 
   /**if control file says true for column definition, write it as first line of the

Modified: db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/load/ImportReadData.java
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/load/ImportReadData.java?rev=358137&r1=358136&r2=358137&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/load/ImportReadData.java
(original)
+++ db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/load/ImportReadData.java
Tue Dec 20 15:04:37 2005
@@ -215,6 +215,7 @@
 
   //open the input data file for reading
   private void realOpenFile() throws Exception {
+	  InputStream inputStream;
     try {
       try {
         URL url = new URL(inputFileName);
@@ -222,11 +223,10 @@
            inputFileName = url.getFile(); //seems like you can't do openstream on file
            throw new MalformedURLException(); //so, get the filename from url and do it ususal
way
         }
-        InputStream inputStream =  url.openStream();
-        bufferedReader = new BufferedReader(new InputStreamReader(inputStream, dataCodeset));
+        inputStream =  url.openStream();
       } catch (MalformedURLException ex) {
-        InputStreamReader inputFileStreamReader = new InputStreamReader(new FileInputStream(inputFileName),
dataCodeset);
-        bufferedReader = new BufferedReader(inputFileStreamReader, 32*1024);
+        inputStream = new FileInputStream(inputFileName);
+        
       }
     } catch (FileNotFoundException ex) {
       throw LoadError.dataFileNotFound(inputFileName);
@@ -237,6 +237,9 @@
 
 		throw sqle;
 	}
+    java.io.Reader rd = dataCodeset == null ?
+    		new InputStreamReader(inputStream) : new InputStreamReader(inputStream, dataCodeset);
   
+    bufferedReader = new BufferedReader(rd, 32*1024);
     streamOpenForReading = true;
   }
 

Modified: db/derby/code/branches/10.1/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedInput.java
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedInput.java?rev=358137&r1=358136&r2=358137&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedInput.java
(original)
+++ db/derby/code/branches/10.1/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedInput.java
Tue Dec 20 15:04:37 2005
@@ -30,7 +30,8 @@
 		super(i);
 		this.in = i;
 	}
-	public LocalizedInput(InputStream i, String encode) throws UnsupportedEncodingException{
+
+	LocalizedInput(InputStream i, String encode) throws UnsupportedEncodingException{
 		super(i,encode);
 		this.in = i;
 	}

Modified: db/derby/code/branches/10.1/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedOutput.java
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedOutput.java?rev=358137&r1=358136&r2=358137&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedOutput.java
(original)
+++ db/derby/code/branches/10.1/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedOutput.java
Tue Dec 20 15:04:37 2005
@@ -30,7 +30,7 @@
 		super(new OutputStreamWriter(o), true);
 		out = o;
 	}
-	public LocalizedOutput(OutputStream o, String enc) throws UnsupportedEncodingException {
+	LocalizedOutput(OutputStream o, String enc) throws UnsupportedEncodingException {
 		super(new OutputStreamWriter(o, enc), true);
 		out = o;
 	}

Modified: db/derby/code/branches/10.1/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedResource.java
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedResource.java?rev=358137&r1=358136&r2=358137&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedResource.java
(original)
+++ db/derby/code/branches/10.1/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedResource.java
Tue Dec 20 15:04:37 2005
@@ -104,10 +104,10 @@
 				encode = eEncode;
 			}
 		}
-		//last chance: get default encoding
-		if (encode == null ){
-		 	encode = new java.io.InputStreamReader(System.in).getEncoding();
-		}
+		
+		// If null at this point then the default encoding
+		// will be always used.
+
 		//get locale string from the caller first
 		locale = getNewLocale(locStr);
 
@@ -127,18 +127,8 @@
 			messageFileName = MESSAGE_FILE;
 		}
 		//create default in/out
-		try {
-			out = new LocalizedOutput(System.out,encode);
-		}
-		catch(UnsupportedEncodingException e){
-			out = new LocalizedOutput(System.out);
-		}
-		try {
-			in = new LocalizedInput(System.in, encode);
-		}
-		catch(UnsupportedEncodingException e){
-			in = new LocalizedInput(System.in);
-		}
+		out = getNewOutput(System.out);
+		in = getNewInput(System.in);
 
 		//for faster code: get the format objs
 		if (enableLocalized && locale != null){
@@ -224,20 +214,23 @@
 	}
 	public LocalizedInput getNewInput(InputStream i) {
 		try {
-			return new LocalizedInput(i,encode);
+			if (encode != null)
+			    return new LocalizedInput(i,encode);
 		}
 		catch (UnsupportedEncodingException e){
-			return new LocalizedInput(i);
+			
 		}
+		return new LocalizedInput(i);
 	}
 
 	public LocalizedOutput getNewOutput(OutputStream o){
 		try {
-			return new LocalizedOutput(o,encode);
+			if (encode != null)
+			    return new LocalizedOutput(o,encode);
 		}
 		catch(UnsupportedEncodingException e){
-			return new LocalizedOutput(o);
 		}
+		return new LocalizedOutput(o);
 	}
 	public String getTextMessage(String key ) {
 		if ( res == null){
@@ -429,9 +422,6 @@
 	}
 	public Locale getLocale(){
 			return locale;
-	}
-	public String getEncode(){
-		return encode;
 	}
 
 	private final synchronized String getEnvProperty(String key) {



Mime
View raw message