#280
Scala SourceTemplateSource read twice, second read is empty
-
-
Created on:
Tue, Jan 31 (4 months ago)
-
Reported by:
rocketraman
-
Assigned to:
-
-
Milestone:
-
-
Estimate:
None/Small/Medium/Large
None
-
Status:
New
-
Priority:
Normal (3)
-
Component:
scalate-core
-
Permission type:
Public
-
-
Followers

rocketraman
No file chosen
You have an empty file field. Please select or remove it.
Associations
| # |
Relation |
Summary |
Status |
Action |
| No tickets |
No associations
Time Expenditure
Loading
Some possible fixes / improvements:
1) Do source.reset on every call to text. This may require the caller to provide a resetFunction. The read will continue to be executed at least twice.
2) Move call to source.text into the match for pipeline, so that source is only read once unless a pipeline is used, in which case it will continue to be executed twice (still requires fix #1 above).
3) Cache the call to the text method in Resource and return the cached value if it has already been called before.
4) Ensure the code never calls source.text twice.
I have submitted https://github.com/scalate/scalate/pull/18 to implement a work-around via #1 and #2 but I suspect you may want to implement the optimal fix #3 or #4.