Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nondeterministic output of processors #219

Open
jglick opened this issue May 5, 2021 · 5 comments
Open

Nondeterministic output of processors #219

jglick opened this issue May 5, 2021 · 5 comments

Comments

@jglick
Copy link
Member

jglick commented May 5, 2021

https://github.com/stapler/stapler/blob/3765ae49d6ff355ab457927eeb5be5776b54817b/core/src/main/java/org/kohsuke/stapler/jsr269/AbstractProcessorImpl.java#L66-L70 can result in build products from a given source tree including a timestamp, breaking artifact diff tools.

It would also be better for *.properties-formatted outputs to be sorted, for maximum stability.

@jglick
Copy link
Member Author

jglick commented May 5, 2021

Can probably just trim() values, and then reimplement

For each entry the key string is written, then an ASCII =, then the associated element string. For the key, all space characters are written with a preceding \ character. For the element, leading space characters, but not embedded or trailing space characters, are written with a preceding \ character. The key and element characters #, !, =, and : are written with a preceding backslash to ensure that they are properly loaded.
Characters not in Latin-1 in the comments are written as \uxxxx for their appropriate unicode hexadecimal value xxxx.
Characters less than \u0020 and characters greater than \u007E in property keys or values are written as \uxxxx for the appropriate hexadecimal value xxxx.

@daniel-beck
Copy link
Member

daniel-beck commented May 24, 2021

This specification cannot be complete, it doesn't mention that \ needs to get a preceding \ as well.

I'm tempted to write to memory and then just dump the first (comment) line before writing to a file. Sorting can probably be done similarly, assuming it never breaks lines for length when programmatically generated.

@jglick
Copy link
Member Author

jglick commented May 24, 2021

dump the first (comment) line

IIRC you can pass an explicit header which overrides the autogenerated date header. You would indeed still need to sort explicitly.

assuming it never breaks lines for length

Not that I know of, but better check.

@daniel-beck
Copy link
Member

IIRC you can pass an explicit header which overrides the autogenerated date header. You would indeed still need to sort explicitly.

https://docs.oracle.com/javase/8/docs/api/java/util/Properties.html#store-java.io.Writer-java.lang.String- documents that the autogenerated comment is always included.

@jglick
Copy link
Member Author

jglick commented May 25, 2021

Indeed. AFAICT you can just | egrep -v '^#' | sort and have it work even for exotic keys and values. (In our cases, the keys are always going to something like Java identifiers so that is probably not a concern, but values can sometimes be multiline strings with whatever characters, right?)

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

No branches or pull requests

2 participants