[ 
https://issues.apache.org/jira/browse/SOLR-13322?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16792166#comment-16792166
 ] 

Uwe Schindler commented on SOLR-13322:
--------------------------------------

Hi,

bq. In the first case there's the additional question of whether or not we can 
suppress just the one bundle (jdk-system-out) or if we have to suppress all 
forbidden apis checks (which is a worrisome thought). 

That won't work, because if you suppress forbidden for some class or method it 
affects all signatures. But there is a trick which I'd propose here!

As said before you can also add {{@SuppressForbidden}} to methods. One way to 
fix this is to add a private static method to the CLI class that just prints a 
line (it's like a mini-logging framework). But in fact it only delegates to 
{{System.out.println()}}. This method is marked with {{@SuppressForbidden}}.

As you have to repeat this for every CLI class, my proposal would be: Define an 
interface with no virtual methods, but exactly one static one (Java 8+ allows 
this). This static method is just there to print a line in CLI. The interface 
could be named {{CommandlineTool}} and the whole interface is marked with 
{{@SuppressForbidden}}.

All CLI programs in solr just implement that interface and can call that 
method. This make the code actually much shorter, as you don't need 
{{System.out}} everywhere.

bq. Also it's worth noting that a there are a couple of other detections 
relating to eclipse generated try/catch blocks that are triggered by removing 
the above line from the build.

Those should be fixed ASAP.

> Enable checking for System.out references in Solr codebase
> ----------------------------------------------------------
>
>                 Key: SOLR-13322
>                 URL: https://issues.apache.org/jira/browse/SOLR-13322
>             Project: Solr
>          Issue Type: Improvement
>      Security Level: Public(Default Security Level. Issues are Public) 
>          Components: Build
>    Affects Versions: master (9.0)
>            Reporter: Gus Heck
>            Priority: Minor
>         Attachments: sysout-forbidden.txt
>
>
> This is almost trivial (just delete this line from the solr build.xml):
> {code:java}
> <target name="-check-forbidden-sysout"/>{code}
> What that line is doing is overriding the top level target that does the 
> checking and makes it do nothing.
> BUT.... unfortunately the "almost" of this is that that instantly detects a 
> large number of things, many of which are valid usages because they are in 
> command line tools that really do want to report information to system out 
> (I'll attach the output)
> This leaves us with two possibilities:
>  # Add @ SuppressForbidden (though there seem to be two of these)
>  # Convert the CLI oriented code to use logging (probably a custom logging 
> config for this use case with no leading date stamp etc...)
> In the first case there's the additional question of whether or not we can 
> suppress just the one bundle (jdk-system-out) or if we have to suppress all 
> forbidden apis checks (which is a worrisome thought). 
> Also it's worth noting that a there are a couple of other detections relating 
> to eclipse generated try/catch blocks that are triggered by removing the 
> above line from the build.
> Conversation on Slack indicates that [~thetaphi] will likely have some 
> thoughts on this.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to