cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter (JIRA)" <>
Subject [jira] [Created] (CB-4504) Attempt to write file to file:///android_asset folder crashes
Date Tue, 06 Aug 2013 01:39:49 GMT
Peter created CB-4504:

             Summary: Attempt to write file to file:///android_asset folder crashes
                 Key: CB-4504
             Project: Apache Cordova
          Issue Type: Bug
          Components: Android
    Affects Versions: 2.9.0
         Environment: Android v4.3 emulator
            Reporter: Peter
            Assignee: Joe Bowser
            Priority: Minor

I wrote a Jasmine test case which attempts to write to the *android_assets* folder. 

The test expects the FileWriter.onerror callback will be called with some appropriate error
code. Instead, Cordova fails internally.

It appears that FileHelper.getRealPath returns null, which the FileUtils.write is not coping
with, and when the null is passed to FileOutputStream that throws NPE, which nobody is handling...

Test code fragment:
it("onerror is called if write to file:///android_asset", function() {
	var theWriter,
	filePath = "file:///android_asset/jumpyfox.txt",

	// file content
	fox = "The quick brown fox";

	// callbacks                
	var onerrorCB = jasmine.createSpy().andCallFake(function(a) {

	// writes initial file content
	var write_file = function(file) {
		theWriter = new FileWriter(file);
		theWriter.onerror = onerrorCB;

	// create file, then write to it
	runs(function() {
		var file = new File();
		file.fullPath = filePath;

	waitsFor(function() { return onerrorCB.wasCalled; }, "onerrorCB never called", Tests.TEST_TIMEOUT);

Maybe other scenarios which call FileHelper.getRealPath could have similar consequences if
it returns null.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:

View raw message