Changeset 6995 in josm


Ignore:
Timestamp:
2014-04-23T02:30:39+02:00 (11 years ago)
Author:
Don-vip
Message:

fix #9906 - fix reliance on default encoding

Location:
trunk
Files:
28 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/OpenFileAction.java

    r6920 r6995  
    1010import java.io.BufferedReader;
    1111import java.io.File;
    12 import java.io.FileReader;
     12import java.io.FileInputStream;
    1313import java.io.IOException;
     14import java.io.InputStreamReader;
    1415import java.util.ArrayList;
    1516import java.util.Arrays;
     
    292293                for (File urlFile: urlFiles) {
    293294                    try {
    294                         BufferedReader reader = new BufferedReader(new FileReader(urlFile));
     295                        BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(urlFile), Utils.UTF_8));
    295296                        String line;
    296297                        while ((line = reader.readLine()) != null) {
  • trunk/src/org/openstreetmap/josm/data/AutosaveTask.java

    r6643 r6995  
    159159                    try {
    160160                        File pidFile = new File(autosaveDir, filename+".pid");
    161                         PrintStream ps = new PrintStream(pidFile);
     161                        PrintStream ps = new PrintStream(pidFile, "UTF-8");
    162162                        ps.println(ManagementFactory.getRuntimeMXBean().getName());
    163163                        Utils.close(ps);
     
    310310                if (pidFile.exists()) {
    311311                    try {
    312                         BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(pidFile)));
     312                        BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(pidFile), Utils.UTF_8));
    313313                        try {
    314314                            String jvmId = reader.readLine();
     
    403403    }
    404404
    405     public void dicardUnsavedLayers() {
     405    public void discardUnsavedLayers() {
    406406        for (File f: getUnsavedLayersFiles()) {
    407407            moveToDeletedLayersFolder(f);
  • trunk/src/org/openstreetmap/josm/data/ServerSidePreferences.java

    r6643 r6995  
    3232public class ServerSidePreferences extends Preferences {
    3333    public static class MissingPassword extends Exception{
    34         public String realm;
     34        public final String realm;
    3535        public MissingPassword(String r) {
    3636            realm = r;
     
    6262                    throw new MissingPassword(t);
    6363                }
    64                 BufferedReader reader = new BufferedReader(new InputStreamReader(con.getInputStream()));
     64                BufferedReader reader = new BufferedReader(new InputStreamReader(con.getInputStream(), Utils.UTF_8));
    6565                StringBuilder b = new StringBuilder();
    6666                try {
     
    9494                con.setDoOutput(true);
    9595                con.connect();
    96                 PrintWriter out = new PrintWriter(new OutputStreamWriter(con.getOutputStream()));
     96                PrintWriter out = new PrintWriter(new OutputStreamWriter(con.getOutputStream(), Utils.UTF_8));
    9797                out.println(s);
    9898                Utils.close(out);
     
    117117    }
    118118
     119    /**
     120     * Constructs a new {@code ServerSidePreferences}.
     121     * @param serverUrl The server URL hosting the user preferences.
     122     */
    119123    public ServerSidePreferences(URL serverUrl) {
    120124        Connection connection = null;
  • trunk/src/org/openstreetmap/josm/data/projection/Projections.java

    r6883 r6995  
    135135        try {
    136136            InputStream in = new MirroredInputStream("resource://data/projection/epsg");
    137             r = new BufferedReader(new InputStreamReader(in));
     137            r = new BufferedReader(new InputStreamReader(in, Utils.UTF_8));
    138138            String line, lastline = "";
    139139            while ((line = r.readLine()) != null) {
  • trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2GridShiftFile.java

    r6990 r6995  
    104104        topLevelSubGrid = null;
    105105        in.read(b8);
    106         String overviewHeaderCountId = new String(b8);
     106        String overviewHeaderCountId = new String(b8, Utils.UTF_8);
    107107        if (!"NUM_OREC".equals(overviewHeaderCountId))
    108108            throw new IllegalArgumentException("Input file is not an NTv2 grid shift file");
  • trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2SubGrid.java

    r6822 r6995  
    7575        in.read(b8);
    7676        in.read(b8);
    77         subGridName = new String(b8).trim();
    78         in.read(b8);
    79         in.read(b8);
    80         parentSubGridName = new String(b8).trim();
    81         in.read(b8);
    82         in.read(b8);
    83         created = new String(b8);
    84         in.read(b8);
    85         in.read(b8);
    86         updated = new String(b8);
     77        subGridName = new String(b8, Utils.UTF_8).trim();
     78        in.read(b8);
     79        in.read(b8);
     80        parentSubGridName = new String(b8, Utils.UTF_8).trim();
     81        in.read(b8);
     82        in.read(b8);
     83        created = new String(b8, Utils.UTF_8);
     84        in.read(b8);
     85        in.read(b8);
     86        updated = new String(b8, Utils.UTF_8);
    8787        in.read(b8);
    8888        in.read(b8);
  • trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java

    r6890 r6995  
    66import java.io.BufferedReader;
    77import java.io.File;
     8import java.io.FileInputStream;
    89import java.io.FileNotFoundException;
    9 import java.io.FileReader;
    10 import java.io.FileWriter;
     10import java.io.FileOutputStream;
    1111import java.io.IOException;
     12import java.io.InputStreamReader;
     13import java.io.OutputStreamWriter;
    1214import java.io.PrintWriter;
    1315import java.util.ArrayList;
     
    171173                BufferedReader in = null;
    172174                try {
    173                     in = new BufferedReader(new FileReader(file));
     175                    in = new BufferedReader(new InputStreamReader(new FileInputStream(file), Utils.UTF_8));
    174176                    for (String line = in.readLine(); line != null; line = in.readLine()) {
    175177                        ignoredErrors.add(line);
     
    197199        PrintWriter out = null;
    198200        try {
    199             out = new PrintWriter(new FileWriter(getValidatorDir() + "ignorederrors"), false);
     201            out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(getValidatorDir() + "ignorederrors"), Utils.UTF_8), false);
    200202            for (String e : ignoredErrors) {
    201203                out.println(e);
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r6920 r6995  
    492492                        autosaveTask.recoverUnsavedLayers();
    493493                    } else if (selection == 3) {
    494                         autosaveTask.dicardUnsavedLayers();
     494                        autosaveTask.discardUnsavedLayers();
    495495                    }
    496496                }
  • trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java

    r6992 r6995  
    2222import java.util.TreeMap;
    2323import java.util.concurrent.CopyOnWriteArrayList;
     24import java.util.zip.CRC32;
    2425
    2526import javax.swing.JComponent;
     
    13261327        String x = center.east() + "_" + center.north() + "_" + scale + "_" +
    13271328                getWidth() + "_" + getHeight() + "_" + getProjection().toString();
    1328         java.util.zip.CRC32 id = new java.util.zip.CRC32();
    1329         id.update(x.getBytes());
     1329        CRC32 id = new CRC32();
     1330        id.update(x.getBytes(Utils.UTF_8));
    13301331        return (int)id.getValue();
    13311332    }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java

    r6969 r6995  
    659659                InputStream is = s.getSourceInputStream();
    660660                try {
    661                     BufferedReader reader = new BufferedReader(new InputStreamReader(is));
     661                    BufferedReader reader = new BufferedReader(new InputStreamReader(is, Utils.UTF_8));
    662662                    try {
    663663                        String line;
  • trunk/src/org/openstreetmap/josm/gui/help/HelpBrowser.java

    r6890 r6995  
    137137        BufferedReader reader = new BufferedReader(
    138138                new InputStreamReader(
    139                         getClass().getResourceAsStream("/data/help-browser.css")
     139                        getClass().getResourceAsStream("/data/help-browser.css"),
     140                        Utils.UTF_8
    140141                )
    141142        );
  • trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java

    r6990 r6995  
    235235                return new XmlStyleSource(entry);
    236236            else {
    237                 InputStreamReader reader = new InputStreamReader(in);
     237                InputStreamReader reader = new InputStreamReader(in, Utils.UTF_8);
    238238                try {
    239239                    WHILE: while (true) {
  • trunk/src/org/openstreetmap/josm/gui/mappaint/xml/XmlStyleSource.java

    r6897 r6995  
    7777            InputStream in = getSourceInputStream();
    7878            try {
    79                 InputStreamReader reader = new InputStreamReader(in);
     79                InputStreamReader reader = new InputStreamReader(in, Utils.UTF_8);
    8080                XmlObjectParser parser = new XmlObjectParser(new XmlStyleSourceHandler(this));
    8181                parser.startWithValidation(reader,
  • trunk/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClient.java

    r6990 r6995  
    214214        BufferedReader r = null;
    215215        try {
    216             r = new BufferedReader(new InputStreamReader(connection.getInputStream()));
     216            r = new BufferedReader(new InputStreamReader(connection.getInputStream(), Utils.UTF_8));
    217217            String c;
    218218            Pattern p = Pattern.compile(".*authenticity_token.*value=\"([^\"]+)\".*");
  • trunk/src/org/openstreetmap/josm/gui/preferences/server/ApiUrlTestTask.java

    r6920 r6995  
    195195            }
    196196            StringBuilder changesets = new StringBuilder();
    197             bin = new BufferedReader(new InputStreamReader(connection.getInputStream()));
     197            bin = new BufferedReader(new InputStreamReader(connection.getInputStream(), Utils.UTF_8));
    198198            String line;
    199199            while ((line = bin.readLine()) != null) {
  • trunk/src/org/openstreetmap/josm/io/CacheFiles.java

    r6889 r6995  
    322322        try {
    323323            MessageDigest md = MessageDigest.getInstance("MD5");
    324             BigInteger number = new BigInteger(1, md.digest(ident.getBytes()));
     324            BigInteger number = new BigInteger(1, md.digest(ident.getBytes(Utils.UTF_8)));
    325325            return number.toString(16);
    326326        } catch(Exception e) {
  • trunk/src/org/openstreetmap/josm/io/NmeaReader.java

    r6889 r6995  
    176176        BufferedReader rd = null;
    177177        try {
    178             rd = new BufferedReader(new InputStreamReader(source));
     178            rd = new BufferedReader(new InputStreamReader(source, Utils.UTF_8));
    179179
    180180            StringBuilder sb = new StringBuilder(1024);
     
    243243            if(chkstrings.length > 1)
    244244            {
    245                 byte[] chb = chkstrings[0].getBytes();
     245                byte[] chb = chkstrings[0].getBytes(Utils.UTF_8);
    246246                int chk=0;
    247247                for (int i = 1; i < chb.length; i++) {
  • trunk/src/org/openstreetmap/josm/io/OsmApi.java

    r6966 r6995  
    191191        @Override
    192192        protected byte[] updateData() throws OsmTransferException {
    193             return sendRequest("GET", "capabilities", null, monitor, false, fastFail).getBytes();
     193            return sendRequest("GET", "capabilities", null, monitor, false, fastFail).getBytes(Utils.UTF_8);
    194194        }
    195195    }
  • trunk/src/org/openstreetmap/josm/io/OsmServerReader.java

    r6882 r6995  
    174174                        InputStream i = fixEncoding(activeConnection.getErrorStream(), encoding);
    175175                        if (i != null) {
    176                             BufferedReader in = new BufferedReader(new InputStreamReader(i));
     176                            BufferedReader in = new BufferedReader(new InputStreamReader(i, Utils.UTF_8));
    177177                            String s;
    178178                            while((s = in.readLine()) != null) {
  • trunk/src/org/openstreetmap/josm/io/imagery/WMSGrabber.java

    r6920 r6995  
    190190        StringBuilder exception = new StringBuilder();
    191191        InputStream in = conn.getInputStream();
    192         BufferedReader br = new BufferedReader(new InputStreamReader(in));
     192        BufferedReader br = new BufferedReader(new InputStreamReader(in, Utils.UTF_8));
    193193        try {
    194194            String line = null;
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/RequestProcessor.java

    r6990 r6995  
    143143        try {
    144144            OutputStream raw = new BufferedOutputStream(request.getOutputStream());
    145             out = new OutputStreamWriter(raw);
     145            out = new OutputStreamWriter(raw, Utils.UTF_8);
    146146            BufferedReader in = new BufferedReader(new InputStreamReader(request.getInputStream(), "ASCII"));
    147147
  • trunk/src/org/openstreetmap/josm/tools/ImageProvider.java

    r6987 r6995  
    543543                } else {
    544544                    try {
    545                         bytes = URLDecoder.decode(data, "utf-8").getBytes();
     545                        bytes = URLDecoder.decode(data, "UTF-8").getBytes(Utils.UTF_8);
    546546                    } catch (IllegalArgumentException ex) {
    547547                        Main.warn("Unable to decode URL data part: "+ex.getMessage() + " (" + data + ")");
     
    550550                }
    551551                if (mediatype != null && mediatype.contains("image/svg+xml")) {
    552                     String s = new String(bytes);
     552                    String s = new String(bytes, Utils.UTF_8);
    553553                    URI uri = getSvgUniverse().loadSVG(new StringReader(s), URLEncoder.encode(s, "UTF-8"));
    554554                    SVGDiagram svg = getSvgUniverse().getDiagram(uri);
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java

    r6977 r6995  
    1010import java.io.BufferedReader;
    1111import java.io.File;
    12 import java.io.FileReader;
     12import java.io.FileInputStream;
    1313import java.io.IOException;
    1414import java.io.InputStreamReader;
     
    227227                // Try lsb_release (only available on LSB-compliant Linux systems, see https://www.linuxbase.org/lsb-cert/productdir.php?by_prod )
    228228                Process p = Runtime.getRuntime().exec("lsb_release -ds");
    229                 BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
     229                BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream(), Utils.UTF_8));
    230230                String line = Utils.strip(input.readLine());
    231231                Utils.close(input);
     
    312312                    BufferedReader reader = null;
    313313                    try {
    314                         reader = new BufferedReader(new FileReader(file));
     314                        reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), Utils.UTF_8));
    315315                        String id = null;
    316316                        String release = null;
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r6977 r6995  
    812812        }
    813813        Process p = new ProcessBuilder(command).start();
    814         BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
     814        BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream(), UTF_8));
    815815        StringBuilder all = null;
    816816        String line;
  • trunk/test/functional/org/openstreetmap/josm/io/MultiFetchServerObjectReaderTest.java

    r6920 r6995  
    1010import java.io.File;
    1111import java.io.FileInputStream;
    12 import java.io.FileWriter;
     12import java.io.FileOutputStream;
    1313import java.io.IOException;
    1414import java.io.InputStream;
     15import java.io.OutputStreamWriter;
    1516import java.io.PrintWriter;
    1617import java.text.MessageFormat;
     
    3637import org.openstreetmap.josm.gui.io.UploadStrategySpecification;
    3738import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
     39import org.openstreetmap.josm.tools.Utils;
    3840
    3941public class MultiFetchServerObjectReaderTest {
     
    211213        try {
    212214            PrintWriter pw = new PrintWriter(
    213                     new FileWriter(dataSetCacheOutputFile)
     215                    new OutputStreamWriter(new FileOutputStream(dataSetCacheOutputFile), Utils.UTF_8)
    214216            );
    215217            logger.info(MessageFormat.format("caching test data set in ''{0}'' ...", dataSetCacheOutputFile.toString()));
  • trunk/test/functional/org/openstreetmap/josm/io/OsmServerBackreferenceReaderTest.java

    r6920 r6995  
    88import java.io.File;
    99import java.io.FileInputStream;
    10 import java.io.FileWriter;
     10import java.io.FileOutputStream;
    1111import java.io.IOException;
    1212import java.io.InputStream;
     13import java.io.OutputStreamWriter;
    1314import java.io.PrintWriter;
    1415import java.text.MessageFormat;
     
    3738import org.openstreetmap.josm.gui.io.UploadStrategySpecification;
    3839import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
     40import org.openstreetmap.josm.tools.Utils;
    3941
    4042public class OsmServerBackreferenceReaderTest {
     
    218220        try {
    219221            PrintWriter pw = new PrintWriter(
    220                     new FileWriter(dataSetCacheOutputFile)
     222                    new OutputStreamWriter(new FileOutputStream(dataSetCacheOutputFile), Utils.UTF_8)
    221223            );
    222224            logger.info(MessageFormat.format("caching test data set in ''{0}'' ...", dataSetCacheOutputFile.toString()));
  • trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRefTest.java

    r6334 r6995  
    33
    44import java.io.BufferedReader;
     5import java.io.FileInputStream;
    56import java.io.FileNotFoundException;
    6 import java.io.FileReader;
    77import java.io.IOException;
     8import java.io.InputStreamReader;
    89import java.util.Collection;
    910import java.util.HashMap;
     
    4849    @Test
    4950    public void test() throws IOException, FileNotFoundException {
    50         BufferedReader in = new BufferedReader(new FileReader("data_nodist/projection-reference-data.csv"));
     51        BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream("data_nodist/projection-reference-data.csv"), Utils.UTF_8));
    5152        StringBuilder fail = new StringBuilder();
    5253        String line;
     
    9293            throw new AssertionError(fail.toString());
    9394        }
    94 
    9595    }
    9696}
  • trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRegressionTest.java

    r6881 r6995  
    55import java.io.BufferedWriter;
    66import java.io.File;
     7import java.io.FileInputStream;
    78import java.io.FileNotFoundException;
    8 import java.io.FileReader;
    9 import java.io.FileWriter;
     9import java.io.FileOutputStream;
    1010import java.io.IOException;
     11import java.io.InputStreamReader;
     12import java.io.OutputStreamWriter;
    1113import java.util.ArrayList;
    1214import java.util.Collection;
     
    2931import org.openstreetmap.josm.gui.preferences.projection.ProjectionPreference;
    3032import org.openstreetmap.josm.tools.Pair;
     33import org.openstreetmap.josm.tools.Utils;
    3134
    3235/**
     
    8790
    8891        Random rand = new Random();
    89         BufferedWriter out = new BufferedWriter(new FileWriter(PROJECTION_DATA_FILE));
     92        BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(PROJECTION_DATA_FILE), Utils.UTF_8));
    9093        out.write("# Data for test/unit/org/openstreetmap/josm/data/projection/ProjectionRegressionTest.java\n");
    9194        out.write("# Format: 1. Projection code; 2. lat/lon; 3. lat/lon projected -> east/north; 4. east/north (3.) inverse projected\n");
     
    112115
    113116    private static List<TestData> readData() throws IOException, FileNotFoundException {
    114         BufferedReader in = new BufferedReader(new FileReader(PROJECTION_DATA_FILE));
     117        BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(PROJECTION_DATA_FILE), Utils.UTF_8));
    115118        List<TestData> result = new ArrayList<TestData>();
    116119        String line;
Note: See TracChangeset for help on using the changeset viewer.