This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 85246 - regression - Japanese characters are garbled in output window
Summary: regression - Japanese characters are garbled in output window
Status: VERIFIED FIXED
Alias: None
Product: serverplugins
Classification: Unclassified
Component: Sun Appserver 8 (show other bugs)
Version: 5.x
Hardware: All All
: P2 blocker (vote)
Assignee: _ ludo
URL:
Keywords: I18N
Depends on:
Blocks:
 
Reported: 2006-09-19 15:30 UTC by Masaki Katakai
Modified: 2007-05-30 04:27 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
screenshot (16.51 KB, image/png)
2006-09-19 15:32 UTC, Masaki Katakai
Details
startserver (40.77 KB, text/plain)
2006-09-26 01:11 UTC, _ ludo
Details
viewer (11.15 KB, text/plain)
2006-09-26 01:11 UTC, _ ludo
Details
viewlog action (5.14 KB, text/plain)
2006-09-26 01:12 UTC, _ ludo
Details
review code (14.92 KB, application/octet-stream)
2006-09-27 20:46 UTC, _ ludo
Details
Updated ViewLogAction.java after review. (14.67 KB, text/plain)
2006-09-28 08:33 UTC, _ pcw
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Masaki Katakai 2006-09-19 15:30:56 UTC
NB: 5.5 daily 0919
OS: Windows XP(Japanese), Linux (ja_JP.UTF-8 locale)
Locale: ja
AS: AS82 PE ml, AS9 PE ml
JDK: 1.5.0_07

See screenshot. Japanese characters are garbled in Output window. It was
working at Beta2, but not working now. I checked 0818 Q-build, it was
not working. Bundled Tomcat is OK.

5.0: OK
5.5 Beta2: OK
5.5 0818: garbled
5.5 0919: garbled

Step:

1. Install ml version of AS82 or AS9
2. Start NB in Japanese locale
3. Register the AS
4. Start the server
5. See output window
Comment 1 Masaki Katakai 2006-09-19 15:32:11 UTC
Created attachment 34163 [details]
screenshot
Comment 2 _ ludo 2006-09-19 18:10:55 UTC
We switch to  RandomFileAccess for the viewer.

similar to old tomcat bug http://www.netbeans.org/issues/show_bug.cgi?id=20331
The fix applied there was to use FileReader:

         boolean takeFocus;
         String prefix,suffix;
         File logFile;
-        RandomAccessFile raf;
+        FileReader fileReader;
         LogThread(String logFilePath, String prefix, String suffix, boolean
takeFocus){
             this.logFilePath=logFilePath;
             this.prefix=prefix;
@@ -1001,28 +1001,24 @@
                     long size = logFile.length();
                     if (size==offset) continue;
                     try {
-                        RandomAccessFile ra = getRandomAccessFile(logFile);
-                        ra.seek(offset);
-                        String line=null;
-                        while ((line=ra.readLine())!=null) {
-                            writer.write(line+'\n'); //NOI18N
+                        try {
+                            fileReader = new FileReader(logFile);
+                            fileReader.skip(offset);
+                            int b;
+                            while ((b=fileReader.read())!=-1)  writer.write(b);
+                        } finally {
+                            if (fileReader!=null) fileReader.close();
                         }
                         wasWritten=true;
                         if (takeFocus) inOut.select();
-                    }catch (IOException ex){}
+                    }catch (IOException ex){
+                        TopManager.getDefault ().getErrorManager ().notify
(ErrorManager.WARNING, ex);
+                    }
                     offset=size;
                 }
             }
             tasks.remove(prefix);
             writer.close();
-            if (raf!=null) try {raf.close();}catch (IOException ex){}
-            
-        }
-        private RandomAccessFile getRandomAccessFile(File file) throws IOException{
-            if (raf==null) {
-                raf = new RandomAccessFile(file,"r"); //NOI18N
-            }
-            return raf;


We need to apply the same one ...
Comment 3 _ ludo 2006-09-25 04:17:05 UTC
Fix almost ready and tested on my *japanese* system...
One more thing to do is to stop the thread and close the log file reader when the server is stopped via the 
IDE to release the lock. this way, we will have same behaviour as before.

Comment 4 _ ludo 2006-09-26 01:11:21 UTC
Created attachment 34477 [details]
startserver
Comment 5 _ ludo 2006-09-26 01:11:49 UTC
Created attachment 34478 [details]
viewer
Comment 6 _ ludo 2006-09-26 01:12:28 UTC
Created attachment 34479 [details]
viewlog action
Comment 7 Petr Blaha 2006-09-26 13:24:19 UTC
Ludo, can you commit the fix in release55_dev. 
Masaki, can you verify this fix in next build from release55_dev.

Thanks
Comment 8 _ ludo 2006-09-27 02:50:20 UTC
Still not ready, not for the japan chars, but when the log file rotates.
Working more with pcw on that as well...
Comment 9 _ ludo 2006-09-27 20:46:35 UTC
Created attachment 34618 [details]
review code
Comment 10 _ ludo 2006-09-27 20:53:53 UTC
I will commit in dev so that the filer can verify the bug. 
I did install japanese local on my system to also verify.
Comment 11 _ pcw 2006-09-28 08:33:12 UTC
Created attachment 34652 [details]
Updated ViewLogAction.java after review.
Comment 12 _ pcw 2006-09-28 08:38:02 UTC
I reviewed the patch, ok to commit to release55_dev for wider testing.
Comment 13 _ pcw 2006-09-28 08:40:48 UTC
Edit -- description of modified review file above is incorrect -- I meant to say
LogViewerSupport.java.  The attachment is the correct file.
Comment 14 _ ludo 2006-09-28 15:20:06 UTC
Checking in LogViewerSupport.java;
/cvs/serverplugins/sun/appsrv81/src/org/netbeans/modules/j2ee/sun/ide/j2ee/LogViewerSupport.java,v
 <--  LogViewerSupport.java
new revision: 1.1.16.3.2.5.2.2; previous revision: 1.1.16.3.2.5.2.1
done
Checking in StartSunServer.java;
/cvs/serverplugins/sun/appsrv81/src/org/netbeans/modules/j2ee/sun/ide/j2ee/StartSunServer.java,v
 <--  StartSunServer.java
new revision: 1.4.4.6.2.19.2.3; previous revision: 1.4.4.6.2.19.2.2
done
Checking in runtime/actions/ViewLogAction.java;
/cvs/serverplugins/sun/appsrv81/src/org/netbeans/modules/j2ee/sun/ide/j2ee/runtime/actions/ViewLogAction.java,v
 <--  ViewLogAction.java
new revision: 1.1.16.1.2.3.2.2; previous revision: 1.1.16.1.2.3.2.1
done
Comment 15 Petr Blaha 2006-09-29 08:40:48 UTC
masaki, can you verify fix in release55_dev build? Thanks
Comment 16 Jindrich Sedek 2006-09-29 09:33:18 UTC
v. in dev branch
Comment 17 Masaki Katakai 2006-09-29 09:57:45 UTC
OK, I will try on my Japanese systems.
Comment 18 Masaki Katakai 2006-09-29 12:58:38 UTC
Verified on 5.5_dev 0929. It works fine on Windows, Linux and Solaris SPARC &
x86 in Japanese locales.
Comment 20 Vince Kraemer 2006-10-02 21:38:50 UTC
*** Issue 86232 has been marked as a duplicate of this issue. ***
Comment 21 Ken Frank 2007-05-30 04:27:01 UTC
v