You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@metamodel.apache.org by "Kasper Sørensen (JIRA)" <ji...@apache.org> on 2014/10/27 18:59:34 UTC

[jira] [Commented] (METAMODEL-89) Racing condition in CsvDataContext

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

Kasper Sørensen commented on METAMODEL-89:
------------------------------------------

Hi Michal,

Good catch! Yes, we should fix this...! I guess a static synchronized block wouldn't be too wasteful here since calling this method is anyways pretty rare I think. But maybe there's an even more effecient way of doing this atomically or with a file lock or something like that.

> Racing condition in CsvDataContext
> ----------------------------------
>
>                 Key: METAMODEL-89
>                 URL: https://issues.apache.org/jira/browse/METAMODEL-89
>             Project: Metamodel
>          Issue Type: Bug
>    Affects Versions: 4.2.0-incubating
>            Reporter: Michał Mela
>
> There seems to be a racing condition in the method that creates a temp file for CsvDataContexts constructed with an InputStream: CsvDataContext.createFileFromInputStream(InputStream inputStream, String encoding) 
> For example, if in thread 1 we get to line 243 while in thread 2 we get to line 240, then, basically, in both threads we have made _sure_ that a file for *the same index in both of the threads* doesn't exist. Then both threads will use the same filename and one thread will overrride the data for another thread's tempfile.
> (the file line numbers were based on this listing: http://grepcode.com/file/repo1.maven.org/maven2/org.eobjects.metamodel/MetaModel-csv/3.4.11/org/eobjects/metamodel/csv/CsvDataContext.java#CsvDataContext)
> The immediate result is that in a thread whose tempfile was overwritten the data context will be created based on wrong data.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)