Skip to content

Fix findbugs encoding issue in VmwareStorageProcessor.java - #460

Closed
rsafonseca wants to merge 1 commit into
apache:masterfrom
rsafonseca:findbugs75
Closed

rsafonseca wants to merge 1 commit into
apache:masterfrom
rsafonseca:findbugs75

Conversation

@rsafonseca

Copy link
Copy Markdown
Contributor

Any encoding would do fine as it's just used to generate a UUID. Sticking with UTF-8 for consistency

Any encoding would do fine as it's just used to generate a UUID. Sticking with UTF-8 for consistency
@asfbot

asfbot commented Jun 15, 2015

Copy link
Copy Markdown

cloudstack-pull-requests #458 SUCCESS
This pull request looks good

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other cases I used Charset.defaultCharset(). Is there a reason to explicitly use "UTF8"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DaanHoogland
Unless you're getting platform specifc data, i think it's best to always stick to use the same charset, to avoid different values from being generated in different platforms whenever possible. Ideally, we should convert all data that comes into the application to a standard charset that supports internationalization such as UTF-8, and just use default platform charset where applicable, when consuming data from platform specific sources.
Using Charset.defaultCharset() will require an extra import and increase the overall size of the class, altough instantiating a String also has its own overhead, i believe it to be less so.. we can also remove string instantiation at runtime by defining a constant, which will also increase runtime efficiency.
Of course this is only my point of view, please comment if you feel otherwise :)

@rsafonseca

Copy link
Copy Markdown
Contributor Author

Here's an example of an instance where i also removed a Charset.defaultCharset() that was placed in the reading of a socket, where cloudstack controls both ends -> #400
If ConsoleProxyCmdHandler.java would run on a different encoding, you might have issues, so i changes all classes that used this to use UTF-8 explicitly. Charset.defaultCharset() should still work on CitrixConsoleProxyLoadCommandWrapper.java (if this runs on the agent side, didn't check) since platform that Xenserver runs on also uses UTF-8 as a default.. but in the off chance the sysadmin screwed with the java defaults or this isn't running on the agent side, it might then fail.. this ensures it would work properly no matter what, it's always safer to do this if you control both the reader and the writer.

And here's an example where i think it's most suited to use Charset.defaultCharset() , the output of a shell command:
#396

It's also possible to screw with the output of this from the system's side (although very unlikely), but this is the best approximation of 100% fail-proof of getting proper encoding of the input data.

@DaanHoogland

Copy link
Copy Markdown
Contributor

thanks, LGTM

@asfgit asfgit closed this in 9f2ebdf Jun 16, 2015
@DaanHoogland

Copy link
Copy Markdown
Contributor

I shouldn't have:( exception uncought. Really curious why the pull request builder accepted this.

@rsafonseca

Copy link
Copy Markdown
Contributor Author

my bad there.. will surround in try/catch block and update

@asfbot

asfbot commented Jun 16, 2015

Copy link
Copy Markdown

Daan Hoogland on dev@cloudstack.apache.org replies:
I think it's caught and also that the pull request builder doesn't
build -Dnoredist. I will check and fix if so

@DaanHoogland

Copy link
Copy Markdown
Contributor

please make it a seperate fix, not an update. I jumped the gun.
or i could revert this one of course

On Tue, Jun 16, 2015 at 10:36 AM, Rafael da Fonseca <
notifications@github.com> wrote:

my bad there.. will surround in try/catch block and update

—
Reply to this email directly or view it on GitHub
#460 (comment).

Daan

@rsafonseca

Copy link
Copy Markdown
Contributor Author

@DaanHoogland done!
#464
I should have checked travis for this one, still my bad :(

kishankavala pushed a commit to kishankavala/cloudstack that referenced this pull request Jun 25, 2015
…ng would do fine as it's just used to generate a UUID. Sticking with UTF-8 for consistency

Signed-off-by: Daan Hoogland <daan.hoogland@gmail.com>

This closes apache#460
shwstppr pushed a commit to shapeblue/cloudstack that referenced this pull request Sep 5, 2024
…QL exception msg improvements (apache#460)

* Don't send sql exception/query from dao to upper layer, log it and send only the error message

* Updated charset to utf8mb4, for display_name column/user_vm table and job_result column/async_job table to support unicode chars & emojis

* Added API arg validator for RFC compliance domain name, to validate VM's host name

* Updated user resources name / display name column's charset to utf8mb4

* Check and update char set for affinity group name to utf8mb4, from the data migration in upgrade path

* Updated backup offering name column charset to utf8mb4

* Added unit tests for vm host/domain name validation

* Added smoke test to check resource name for vm, volume, service & disk offering, template, iso, account(first/lastname)

* Updated resource annotation charset to utf8mb4

* Updated some resources description charset to utf8mb4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants