GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Avoid FileReader · Issue #1537 · googleapis/google-cloud-java

Avoid FileReader #1537

New issue
Copy link
New issue
Copy link
Closed
Closed
Avoid FileReader#1537
Copy link
Assignees
yihanzhen
Labels
api: corepriority: p2Moderately-important priority. Fix may not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Description

@elharo
elharo
opened on Jan 14, 2017
Issue body actions

Noticed you're using FileReader in com.google.cloud.ServiceOptions and possibly elsewhere. This is potentially buggy because it depends on the platform default encoding and thus behavior can change from one system to the next. Instead, try an InputStreamReader with a specified encoding chained to a FileInputStream.

protected static String googleCloudProjectId() {
    File configDir;
    if (System.getenv().containsKey("CLOUDSDK_CONFIG")) {
      configDir = new File(System.getenv("CLOUDSDK_CONFIG"));
    } else if (isWindows() && System.getenv().containsKey("APPDATA")) {
      configDir = new File(System.getenv("APPDATA"), "gcloud");
    } else {
      configDir = new File(System.getProperty("user.home"), ".config/gcloud");
    }
    String activeConfig = activeGoogleCloudConfig(configDir);
    FileReader fileReader = null;
    try {
      fileReader = new FileReader(new File(configDir, "configurations/config_" + activeConfig));
    } catch (FileNotFoundException newConfigFileNotFoundEx) {
      try {
        fileReader = new FileReader(new File(configDir, "properties"));
      } catch (FileNotFoundException oldConfigFileNotFoundEx) {
        // ignore
      }
}

Activity

  1. garrettjonesgoogle
    added
    api: core
    on Jan 26, 2017
  2. vam-google
    added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    priority: p2Moderately-important priority. Fix may not be included in next release.
    on May 24, 2017
  3. garrettjonesgoogle commented on Aug 10, 2017

    @garrettjonesgoogle
    garrettjonesgoogle
    on Aug 10, 2017
    Contributor
    More actions

    @elharo Do we know that the encoding of the configuration files will always be the same?

  4. elharo commented on Aug 10, 2017

    @elharo
    elharo
    on Aug 10, 2017
    ContributorAuthor
    More actions

    The problem is that you can't assume it is the native encoding of the platform. I.e. there is no guarantee that FileReader() does the right thing.

    You'd have to ask gcloud what character set they use.

  5. anthmgoogle
    added
    type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.
    and removed
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    on Nov 9, 2017
  6. yihanzhen commented on Jan 11, 2018

    @yihanzhen
    yihanzhen
    on Jan 11, 2018
    Contributor
    More actions

    The feature request is added to the backlog. The issue will be closed but is linked in the backlog and can continue to be used for comment and discussion.

  7. yihanzhen
    closed this as completedon Jan 11, 2018
  8. JustinBeckwith
    assigned
    yihanzhen
    on Feb 1, 2021
  9. meltsufin
    added a commit that references this issue on Dec 22, 2025

    test(deps): update dependency com.google.truth:truth to v1.4.0 (#1537)

    2c36b1e
  10. chingor13
    added a commit that references this issue on Jan 6, 2026

    deps: update dependency com.google.cloud:sdk-platform-java-config to …

    e58b11c
  11. chingor13
    added a commit that references this issue on Jan 22, 2026

    feat: Introducing Tracing with OpenTelemetry API #1537 (#1576)

    5440c22
  12. suztomo
    added a commit that references this issue on Mar 11, 2026

    test(deps): update dependency com.google.truth:truth to v1.4.0 (googl…

    88e2fdc
  13. lqiu96
    added a commit that references this issue on Mar 20, 2026

    deps: update dependency com.google.cloud:sdk-platform-java-config to …

    9475b45
  14. suztomo
    added 2 commits that reference this issue on Mar 23, 2026

    deps: update dependency com.google.cloud:sdk-platform-java-config to …

    114c594

    chore(main): release 2.16.1 (googleapis#1534)

    a2f1267
  15. suztomo
    added a commit that references this issue on Mar 30, 2026

    deps: update dependency com.google.cloud:google-cloud-storage to v2.4…

    f417632
  16. lqiu96
    added a commit that references this issue on Apr 1, 2026

    deps: update dependency com.google.cloud:google-cloud-storage to v2.4…

    729b062
  17. benjaminp
    added 2 commits that reference this issue on Jul 13, 2026

    deps: update dependency org.graalvm.buildtools:junit-platform-native …

    22f2cc5

    chore(main): release 2.17.0 (googleapis#1516)

    9007887
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @yihanzhen
    yihanzhen

Labels

api: corepriority: p2Moderately-important priority. Fix may not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.