Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-26203] Android: Prevent exception in Log for HTTP response #10175

Merged
merged 6 commits into from Jul 20, 2018

Conversation

ypbnv
Copy link
Contributor

@ypbnv ypbnv commented Jul 12, 2018

JIRA: https://jira.appcelerator.org/browse/TIMOB-26203

Description:
Guard for a null response from the server.

Note: Can we have a unit test for that?

Test case:

var url = "https://www.appcelerator.org/exit.xml";

Ti.API.info("checkURL - Checking URL: " + url);
// createHTTPClient       
var client = Ti.Network.createHTTPClient({
  onload : function(e) {
    // if success do           
    Ti.API.info("checkURL Success - URL Found: " + url);
  },
  onerror : function(e) {
    // on error do            
    Ti.API.info("checkURL Error - File URL Not Found");
  },
});

// open the connection with client.open with method and url
client.open('HEAD', url);
// Send the request.
client.send(); 

@ypbnv ypbnv added this to the 7.4.0 milestone Jul 12, 2018
@ypbnv ypbnv requested a review from garymathews July 12, 2018 09:40
Copy link
Contributor

@garymathews garymathews left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CR: PASS

Yes, we should be able to write a test case for this

@sgtcoolguy
Copy link
Contributor

@ypbnv I mean does that manual test case you wrote above work to expose the issue and passes after the fix? If so, that's pretty easy to write up as a mocha test:

describe('Ti.Network.HTTPClient', function () {
  it('handles null input stream in response', function (finish) {
    var url = "https://www.appcelerator.org/exit.xml";
    var client = Ti.Network.createHTTPClient({
      onload : function(e) {   
        finish(new Error('Expected network call to fail'));
      },
      onerror : function(e) {
      // TODO: Test some of the event callback properties?
       finish();
      },
    });

    client.open('HEAD', url);
    client.send();
  });
});

@ypbnv
Copy link
Contributor Author

ypbnv commented Jul 18, 2018

@sgtcoolguy If I understand the test case you proposed right it will pass if the onerror callback is called, right? Which is the case before this fix, but it will log an Android exception too.

@lokeshchdhry
Copy link
Contributor

FR Passed.

If url is not present & server returns null then checkURL Error - File URL Not Found is logged.

Studio Ver: 5.1.0.201807181611
SDK Ver: 7.4.0 local build
OS Ver: 4.2.13
Xcode Ver: 7.0.4
Appc NPM: 1.1.3
Appc CLI: 10.13.5
Daemon Ver: Xcode 9.4.1
Ti CLI Ver: 5.1.1
Alloy Ver: 1.12.0
Node Ver: 8.9.1
NPM Ver: 5.5.1
Java Ver: 10.0.1
Devices: ⇨ google Nexus 5 (Android 6.0.1)
⇨ google Nexus 6P (Android 8.1.0)
Emulator: ⇨ Android 4.1.2

@build
Copy link
Contributor

build commented Jul 20, 2018

Messages
📖

💾 Here's the generated SDK zipfile.

Generated by 🚫 dangerJS

@hansemannn hansemannn merged commit 38a720d into tidev:master Jul 20, 2018
@hansemannn hansemannn modified the milestones: 7.4.0, 7.5.0 Aug 24, 2018
dieskim pushed a commit to dieskim/titanium_mobile that referenced this pull request Nov 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants