Skip to content
This repository was archived by the owner on Aug 17, 2018. It is now read-only.

Commit 9c37a8c

Browse files
author
Kin Man Chung
committed
Fix findbugs errors and warnings.
svn path=/trunk/; revision=1417
1 parent 4d0d38b commit 9c37a8c

4 files changed

Lines changed: 20 additions & 51 deletions

File tree

impl/src/main/java/org/apache/jasper/JspC.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,12 @@
6464
import java.io.FileInputStream;
6565
import java.io.FileNotFoundException;
6666
import java.io.FileOutputStream;
67-
import java.io.FileReader;
68-
import java.io.FileWriter;
67+
import java.io.InputStreamReader;
68+
import java.io.OutputStreamWriter;
6969
import java.io.IOException;
7070
import java.io.PrintWriter;
7171
import java.io.Writer;
72+
import java.io.UnsupportedEncodingException;
7273
// START GlassFish 750
7374
import java.util.concurrent.ConcurrentHashMap;
7475
// END GlassFish 750
@@ -1021,10 +1022,12 @@ protected void mergeIntoWebXml() throws IOException {
10211022
String insertEndMarker =
10221023
Localizer.getMessage("jspc.webinc.insertEnd");
10231024

1024-
BufferedReader reader = new BufferedReader(new FileReader(webXml));
1025-
BufferedReader fragmentReader =
1026-
new BufferedReader(new FileReader(webxmlFile));
1027-
PrintWriter writer = new PrintWriter(new FileWriter(webXml2));
1025+
BufferedReader reader = new BufferedReader(
1026+
new InputStreamReader(new FileInputStream(webXml),"UTF-8"));
1027+
BufferedReader fragmentReader = new BufferedReader(
1028+
new InputStreamReader(new FileInputStream(webxmlFile),"UTF-8"));
1029+
PrintWriter writer = new PrintWriter(
1030+
new OutputStreamWriter(new FileOutputStream(webXml2),"UTF-8"));
10281031

10291032
// Insert the <servlet> and <servlet-mapping> declarations
10301033
int pos = -1;
@@ -1415,7 +1418,7 @@ private void initWebXml() {
14151418
try {
14161419
if (webxmlLevel >= INC_WEBXML) {
14171420
File fmapings = new File(webxmlFile);
1418-
mapout = new FileWriter(fmapings);
1421+
mapout = new OutputStreamWriter(new FileOutputStream(fmapings),"UTF-8");
14191422
servletout = new CharArrayWriter();
14201423
mappingout = new CharArrayWriter();
14211424
} else {
@@ -1457,7 +1460,8 @@ private void completeWebXml() {
14571460
private void initServletContext() {
14581461
try {
14591462
context =new JspCServletContext
1460-
(new PrintWriter(System.out),
1463+
(new PrintWriter(new OutputStreamWriter(System.out, "UTF-8")),
1464+
14611465
new URL("file:" + uriRoot.replace('\\','/') + '/'));
14621466
tldScanner = new TldScanner(context, isValidationEnabled);
14631467

@@ -1471,6 +1475,7 @@ private void initServletContext() {
14711475
// END GlassFish 750
14721476
} catch (MalformedURLException me) {
14731477
System.out.println("**" + me);
1478+
} catch (UnsupportedEncodingException ex) {
14741479
}
14751480
rctxt = new JspRuntimeContext(context, this);
14761481
jspConfig = new JspConfig(context);

impl/src/main/java/org/apache/jasper/compiler/ELParser.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,8 @@ private Token nextToken() {
273273
if (Character.isJavaIdentifierStart(ch)) {
274274
StringBuilder buf = new StringBuilder();
275275
buf.append(ch);
276-
while ((ch = peekChar()) != -1 &&
277-
Character.isJavaIdentifierPart(ch)) {
276+
while (peekChar() != -1 &&
277+
Character.isJavaIdentifierPart(ch=(char)peekChar())) {
278278
buf.append(ch);
279279
nextChar();
280280
}
@@ -340,9 +340,9 @@ private char nextChar() {
340340
return expression.charAt(index++);
341341
}
342342

343-
private char peekChar() {
343+
private int peekChar() {
344344
if (index >= expression.length()) {
345-
return (char)-1;
345+
return -1;
346346
}
347347
return expression.charAt(index);
348348
}

impl/src/main/java/org/apache/jasper/runtime/BodyContentImpl.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
import java.io.PrintWriter;
6464
import java.io.Reader;
6565
import java.io.Writer;
66+
import java.io.OutputStreamWriter;
6667
import javax.servlet.ServletResponse;
6768
import javax.servlet.jsp.JspWriter;
6869
import javax.servlet.jsp.tagext.BodyContent;
@@ -594,7 +595,8 @@ public static void main (String[] args) throws Exception {
594595
= new BodyContentImpl(new JspWriterImpl(null, 100, false));
595596
bodyContent.println (buff);
596597
System.out.println (bodyContent.getString ());
597-
bodyContent.writeOut (new PrintWriter (System.out));
598+
bodyContent.writeOut (new PrintWriter(
599+
new OutputStreamWriter(System.out,"UTF-8")));
598600
}
599601

600602
/**

impl/src/main/java/org/apache/jasper/runtime/JspRuntimeLibrary.java

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -604,44 +604,6 @@ public static String escapeQueryString(String unescString) {
604604
return escString;
605605
}
606606

607-
/**
608-
* Decode an URL formatted string.
609-
* @param encoded The string to decode.
610-
* @return The decoded string.
611-
*/
612-
613-
public static String decode(String encoded) {
614-
// speedily leave if we're not needed
615-
if (encoded == null) return null;
616-
if (encoded.indexOf('%') == -1 && encoded.indexOf('+') == -1)
617-
return encoded;
618-
619-
//allocate the buffer - use byte[] to avoid calls to new.
620-
byte holdbuffer[] = new byte[encoded.length()];
621-
622-
char holdchar;
623-
int bufcount = 0;
624-
625-
for (int count = 0; count < encoded.length(); count++) {
626-
char cur = encoded.charAt(count);
627-
if (cur == '%') {
628-
holdbuffer[bufcount++] =
629-
(byte)Integer.parseInt(encoded.substring(count+1,count+3),16);
630-
if (count + 2 >= encoded.length())
631-
count = encoded.length();
632-
else
633-
count += 2;
634-
} else if (cur == '+') {
635-
holdbuffer[bufcount++] = (byte) ' ';
636-
} else {
637-
holdbuffer[bufcount++] = (byte) cur;
638-
}
639-
}
640-
// REVISIT -- remedy for Deprecated warning.
641-
//return new String(holdbuffer,0,0,bufcount);
642-
return new String(holdbuffer,0,bufcount);
643-
}
644-
645607
// __begin lookupReadMethodMethod
646608
public static Object handleGetProperty(Object o, String prop)
647609
throws JasperException {

0 commit comments

Comments
 (0)