Eclipse configuration : are you sure you reached the end of file ?



  • Seen in Eclipse 3.2 WTP configuration (config.ini).

    It seems Eclipse developpers were not sure to reach the end of file, so they put their own marcker. Are they so paranoid they fear for the InputStream never ending ? Are they affraid of an attack from the bytes after the end of the file ?

    # End of file marker - must be here
    eof=eof

     

    Note : eof=oeof are actually the last bytes in the config.ini, there is no line feed/carriage return on this final line. The comment suggest you must not move this line, so I wonder : what will happen if...



  • [quote user="Kilwch"]

    Seen in Eclipse 3.2 WTP configuration (config.ini).

    It seems Eclipse developpers were not sure to reach the end of file, so they put their own marcker. Are they so paranoid they fear for the InputStream never ending ? Are they affraid of an attack from the bytes after the end of the file ?

    # End of file marker - must be here
    eof=eof

     

    Note : eof=oeof are actually the last bytes in the config.ini, there is no line feed/carriage return on this final line. The comment suggest you must not move this line, so I wonder : what will happen if...

    [/quote]

     

    I'd say they don't want to work with a broken (incomplete) config file, so they mark the real end of the file; I guess Eclipse issues a warning when this marker is missing? 



  • [quote user="ammoQ"]

    I'd say they don't want to work with a broken (incomplete) config file, so they mark the real end of the file; I guess Eclipse issues a warning when this marker is missing? 

    [/quote]

    You're right.

    I traced all the way back here:  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.platform/src/org/eclipse/core/launcher/Main.java?rev=1.1&content-type=text/vnd.viewcvs-markup

    Check out this method:

     /
    Load the configuration 
    */
    private Properties load(URL url) throws IOException {

    ...
     // check to see if we have complete config file
    if (!CFG_EOF.equals(props.getProperty(CFG_EOF))) {
     throw new IOException();
    }

           

     



  • OK so if there is ONLY eof=eof in the config file, it will be considered as complete ? WTF ?



  • [quote user="Kilwch"]OK so if there is ONLY eof=eof in the config file, it will be considered as complete ? WTF ?
    [/quote]

    Why is that so troubling to you?

     An XML tag is only complete if it has a matching ending tag.  A curly brace is only complete if it has a matching closing curly brace. And on and on .....

    These are called specifications.  It's a way to make sure that your data or file is properly structured and not corrupt.  Pretty standard stuff.



     



  • Checking the most recent version of the config loading method, such eof detection has been removed:

    See "private Properties load(URL url, String suffix) throws IOException "

    I'm thinking this might relate to an early buggy version of java.io.InputStream, 1.3.1 maybe?



  • [quote user="Kilwch"]OK so if there is ONLY eof=eof in the config file, it will be considered as complete ? WTF ?
    [/quote]


    It protects you against little things like a truncated download or a file server error.  If you've only got half a config file and don't know it, Very Bad Things can happen.



  • [quote user="HiugongGwok"][quote user="ammoQ"]

    I'd say they don't
    want to work with a broken (incomplete) config file, so they mark the
    real end of the file; I guess Eclipse issues a warning when this marker
    is missing? 

    [/quote]

    You're right.

    I traced all the way back here:  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.platform/src/org/eclipse/core/launcher/Main.java?rev=1.1&content-type=text/vnd.viewcvs-markup

    Check out this method:

     /
    Load the configuration 
    */
    private Properties load(URL url) throws IOException {

    ...
     // check to see if we have complete config file
    if (!CFG_EOF.equals(props.getProperty(CFG_EOF))) {
     throw new IOException();
    }

           

     [/quote]

    That
    in itself is a nasty WTF.  An IOException with no error
    message?  That means the poor developer gets a generic error
    message like "Something went wrong loading the config file" with no
    indication of why.  (The proper thing to do, actually, is not to
    provide a String parameter, but to create a subclass of IOException
    like ConfigurationTruncatedException and throw that.)



  • [quote user="VGR"]That in itself is a nasty WTF.  An IOException with no error message?  That means the poor developer gets a generic error message like "Something went wrong loading the config file" with no indication of why.  (The proper thing to do, actually, is not to provide a String parameter, but to create a subclass of IOException like ConfigurationTruncatedException and throw that.)
    [/quote]

    Yes, however it should be a ConfigurationAppearsToBeTruncatedBecauseTheFileDidntEndWithEofEqualsEofException and when caught, a dialog should appear saying:

    A ConfigurationAppearsToBeTruncatedBecauseTheFileDidntEndWithEofEqualsEofException Exception occured.

    Would you like to ignore this error and continue, attempt to fix the error and continue or cancel the current operation?

    <YES> <No>



  • [quote user="Kilwch"]

    Seen in Eclipse 3.2 WTP configuration (config.ini).

    It seems Eclipse developpers were not sure to reach the end of file, so they put their own marcker. Are they so paranoid they fear for the InputStream never ending ? Are they affraid of an attack from the bytes after the end of the file ?

    # End of file marker - must be here
    eof=eof

     

    Note : eof=oeof are actually the last bytes in the config.ini, there is no line feed/carriage return on this final line. The comment suggest you must not move this line, so I wonder : what will happen if...

    [/quote]
    <font face="tahoma,arial,helvetica,sans-serif">They could just however change the extension to a different one if they needed a different specification for the end of file... That way, users are aware that it's not just a typical .INI file...



    </font>



  • [quote user="Some Idiot"]

    [quote user="VGR"]That in itself is a nasty WTF.  An IOException with no error message?  That means the poor developer gets a generic error message like "Something went wrong loading the config file" with no indication of why.  (The proper thing to do, actually, is not to provide a String parameter, but to create a subclass of IOException like ConfigurationTruncatedException and throw that.)
    [/quote]

    Yes, however it should be a ConfigurationAppearsToBeTruncatedBecauseTheFileDidntEndWithEofEqualsEofException and when caught, a dialog should appear saying:

    A ConfigurationAppearsToBeTruncatedBecauseTheFileDidntEndWithEofEqualsEofException Exception occured.

    Would you like to ignore this error and continue, attempt to fix the error and continue or cancel the current operation?

    <YES> <No>

    [/quote]
    <font face="tahoma,arial,helvetica,sans-serif">I can already picture devs looking closer to check what the error really is... Was it a ConfigurationAppearsToBeTruncatedBecauseTheFileDidntEndWithEofEqualsEofException Exception, or a
    ConfigurationAppearsToBeTruncatedBecauseTheFileHasMoreThan1EofEqualsEofException Exception?



    </font>


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.