问:
How can I convert a string to the idna coded, encoding with 'idna' coded failed
I have a string, which should be a stmp server in a later step for python.

The string is (little anonymized):

outlook-stg.d-a-tf.de/mapi/emsmdb/?MailboxId=cf27be4f-8605-40e4-94ab-d8cea3cc03bc@test.com

For sure the error is:

UnicodeError: encoding with 'idna' codec failed (UnicodeError: label
  empty or too long)

Which I understand is a problem with the name how I want to adress the server: label empty or too long - python urllib2

But how can I convert it in the right format? I also tried: Encoding with 'idna' codec failed in RethinkDB

With this code: .encode("idna") but this also is the same error.

答:
IDNA is an algorithm used to encode domain names, or hostnames. What you provide as example is an URL, so it includes characters that can not work in a domain name and hence can not be encoded and hence your error.

You need to separate the domain (host) name from the rest, apply IDNA only to it (but useless in your example as your hostname is purely ASCII already), and reconstruct your URL.

The specific error you quote comes from the following fact: as IDNA deals with names, per the DNS definition, it works at the label level. A label is somethings between dots, so first step is to split things.
Your string is then handled that way:

outlook-stg

d-a-tf

de/mapi/emsmdb/?MailboxId=cf27be4f-8605-40e4-94ab-d8cea3cc03bc@test

com

And a label in the DNS can not be more than 63 bytes. Your third string, even for now not considering that it has disallowed characters (like @)  that can never happen in a domain name, even with IDNA encoding, is 68 bytes long, hence the exact error you get.

If I artificially shrink it I then get another error, as expected based on above explanations:

```<code>>>> print(idna.encode('outlook-stg.d-a-tf.de/mapi/emsmdb/?MId=cf27be4f-8605-40e4-94ab-d8cea3cc03bc@test.com'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/idna/core.py", line 358, in encode
    s = alabel(label)
  File "/usr/local/lib/python3.7/site-packages/idna/core.py", line 270, in alabel
    ulabel(label)
  File "/usr/local/lib/python3.7/site-packages/idna/core.py", line 304, in ulabel
    check_label(label)
  File "/usr/local/lib/python3.7/site-packages/idna/core.py", line 261, in check_label
    raise InvalidCodepoint('Codepoint {0} at position {1} of {2} not allowed'.format(_unot(cp_value), pos+1, repr(label)))
idna.core.InvalidCodepoint: Codepoint U+002F at position 3 of 'de/mapi/emsmdb/?mid=cf27be4f-8605-40e4-94ab-d8cea3cc03bc@test' not allowed
</code>```

(U+002F is / of course, another character disallowed in a domain name, hence rejected during IDNA encoding)

Note that there are rules also to encoding "non ascii characters" in other parts of the URL, that is the path, which is why the top governing standard is now IRI: RFC 3987
It says, even if in a convoluted way, exactly the above:

Replace the ireg-name part of the IRI by the part converted using
  the    ToASCII operation specified in section 4.1 of [RFC3490] on each
  dot-separated label, and by using U+002E (FULL STOP) as a label

  separator, with the flag UseSTD3ASCIIRules set to TRUE, and with the

  flag AllowUnassigned set to FALSE for creating IRIs and set to TRUE

  otherwise.

So, depending on your needs, you should:

Parse your string as an URI/IRI (with a proper library, do not expect to do it properly with a regex yourself)

Now that you have the hostname part, you can apply IDNA on it, as needed (but the URI/IRI parsing library may do the work for you in fact already, so double check)

And reconstruct the full URI/IRI if you want after that.

Body:
IDNA is an algorithm used to encode domain names, or hostnames. What you provide as example is an URL, so it includes characters that can not work in a domain name and hence can not be encoded and hence your error.

You need to separate the domain (host) name from the rest, apply IDNA only to it (but useless in your example as your hostname is purely ASCII already), and reconstruct your URL.

The specific error you quote comes from the following fact: as IDNA deals with names, per the DNS definition, it works at the label level. A label is somethings between dots, so first step is to split things.
Your string is then handled that way:

outlook-stg

d-a-tf

de/mapi/emsmdb/?MailboxId=cf27be4f-8605-40e4-94ab-d8cea3cc03bc@test

com

And a label in the DNS can not be more than 63 bytes. Your third string, even for now not considering that it has disallowed characters (like @)  that can never happen in a domain name, even with IDNA encoding, is 68 bytes long, hence the exact error you get.

If I artificially shrink it I then get another error, as expected based on above explanations:

>>> print(idna.encode('outlook-stg.d-a-tf.de/mapi/emsmdb/?MId=cf27be4f-8605-40e4-94ab-d8cea3cc03bc@test.com'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/idna/core.py", line 358, in encode
    s = alabel(label)
  File "/usr/local/lib/python3.7/site-packages/idna/core.py", line 270, in alabel
    ulabel(label)
  File "/usr/local/lib/python3.7/site-packages/idna/core.py", line 304, in ulabel
    check_label(label)
  File "/usr/local/lib/python3.7/site-packages/idna/core.py", line 261, in check_label
    raise InvalidCodepoint('Codepoint {0} at position {1} of {2} not allowed'.format(_unot(cp_value), pos+1, repr(label)))
idna.core.InvalidCodepoint: Codepoint U+002F at position 3 of 'de/mapi/emsmdb/?mid=cf27be4f-8605-40e4-94ab-d8cea3cc03bc@test' not allowed

(U+002F is / of course, another character disallowed in a domain name, hence rejected during IDNA encoding)

Note that there are rules also to encoding "non ascii characters" in other parts of the URL, that is the path, which is why the top governing standard is now IRI: RFC 3987
It says, even if in a convoluted way, exactly the above:

Replace the ireg-name part of the IRI by the part converted using
  the    ToASCII operation specified in section 4.1 of [RFC3490] on each
  dot-separated label, and by using U+002E (FULL STOP) as a label

  separator, with the flag UseSTD3ASCIIRules set to TRUE, and with the

  flag AllowUnassigned set to FALSE for creating IRIs and set to TRUE

  otherwise.

So, depending on your needs, you should:

Parse your string as an URI/IRI (with a proper library, do not expect to do it properly with a regex yourself)

Now that you have the hostname part, you can apply IDNA on it, as needed (but the URI/IRI parsing library may do the work for you in fact already, so double check)

And reconstruct the full URI/IRI if you want after that.


来源: stackexchange

问:
How does sizeof work for int types?
I have a small program which compares </p>

<p>(1) sizeof,
(2) numeric_limits::digits,
(3) and the results of a loop </p>

<p>in an effort to make sure they all report the same thing regarding the size of the "int types" on any C++ implementation.  However because I don't know about the internals of sizeof, I have to wonder if it is just reporting numeric_limits::digits.  Thanks </p>

答:
The sizeof operator is a compile time construct by which the compiler reports the size, in bytes, that an instance of the given type will occupy in memory.

It's hard to give a general "this is how sizeof works" answer because it's specific to every compiler implementation.  In general though it works by computing the size of every field of a type and adding them together while accounting for alignment.

For example here's a reasonable set of outputs [1]

```<code>struct S1 {
  int field1;
  int field2;
};

struct S2 {
  int field1;
  bool field2;
  int field3;
}

sizeof(S1) == 8
sizeof(S2) == 12;
</code>```

The reason many compilers will report the size of S2 as 12 as opposed to 9 is that it must account for alignment issues and hence insert 3 bytes to make up for the gap between field2 and field3

[1] Note: I said reasonable not guaranteed :). C compiles have a lot of flexibility in sizes and it's nearly impossible to state specifics about sizes without knowing the compiler you're working with

ContentLicense: CC BY-SA 3.0

Title: How does sizeof work for int types?

Body:
I have a small program which compares

(1) sizeof,
(2) numeric_limits::digits,
(3) and the results of a loop

in an effort to make sure they all report the same thing regarding the size of the "int types" on any C++ implementation.  However because I don't know about the internals of sizeof, I have to wonder if it is just reporting numeric_limits::digits.  Thanks

Body:
The sizeof operator is a compile time construct by which the compiler reports the size, in bytes, that an instance of the given type will occupy in memory.

It's hard to give a general "this is how sizeof works" answer because it's specific to every compiler implementation.  In general though it works by computing the size of every field of a type and adding them together while accounting for alignment.

For example here's a reasonable set of outputs [1]

struct S1 {
  int field1;
  int field2;
};

struct S2 {
  int field1;
  bool field2;
  int field3;
}

sizeof(S1) == 8
sizeof(S2) == 12;

The reason many compilers will report the size of S2 as 12 as opposed to 9 is that it must account for alignment issues and hence insert 3 bytes to make up for the gap between field2 and field3

[1] Note: I said reasonable not guaranteed :). C compiles have a lot of flexibility in sizes and it's nearly impossible to state specifics about sizes without knowing the compiler you're working with


问:
Split array into different size chunks (4, 3, 3, 3, 4, 3, 3, 3, etc)
I have an array like so: [1, 2, 3, 4, 5, 6, 7, 9, 10]. I need to chunk it into different size chunks, yet with a simple pattern of: 4, 3, 3, 3, 4, 3, 3, 3 like so:

```<code>[
    [ // four
        1,
        2,
        3,
        4
    ],
    [ // three (1/3)
        5,
        6,
        7
    ],
    [ // three (2/3)
        8,
        9,
        10
    ],
    [ // three (3/3)
        11,
        12,
        13
    ],
    [ // four
        14,
        15,
        16,
        17
    ],
    [ // three (1/3)
        18,
        19,
        20
    ], // and so on..
]
</code>```

I have tried with this code I have customized:

```<code>const arr; // my array of values
const chuncked = arr.reduce((acc, product, i) => {
    if (i % 3) {
        return acc;
    } else if (!didFourWayReduce) {
        didFourWayReduce = true;
        fourWayReduces++;

        if ((fourWayReduces - 1) % 2) { // only make every second a "4 row"
            return [...acc, arr.slice(i, i + 3)];
        } else {
            return [...acc, arr.slice(i, i + 4)];
        }
    } else {
        didFourWayReduce = false;
        return [...acc, arr.slice(i, i + 3)];
    }
}, []);
</code>```

And it works, almost, expect that the first chunk of threes (1/3) have the last element of the chunk with 4. So 1 key is repeated every first chunk of three. Like so:

```<code>[
    [
        1,
        2,
        3,
        4
    ],
    [
        4, // this one is repeated, and it shouldn't be
        5,
        6
    ]
]
</code>```

答:
A recursive approach is fairly elegant:

const chunks = (xs, [s, ...ss]) =>
  xs.length ? [xs .slice (0, s), ... chunks (xs .slice (s), [...ss, s])] : []

const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
const sizes = [4, 3, 3, 3]

console .log (chunks (data, sizes))```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.as-console-wrapper { max-height: 100% !important; top: 0; }</code>```

By replacing [s, ...ss] with [...ss, s], we pass a cycled version of the sizes array, so that for instance, [4, 3, 3, 3] becomes [3, 3, 3, 4].  This makes it easy to parse step-by-step.

ContentLicense: CC BY-SA 4.0

Body:
I have an array like so: [1, 2, 3, 4, 5, 6, 7, 9, 10]. I need to chunk it into different size chunks, yet with a simple pattern of: 4, 3, 3, 3, 4, 3, 3, 3 like so:

[
    [ // four
        1,
        2,
        3,
        4
    ],
    [ // three (1/3)
        5,
        6,
        7
    ],
    [ // three (2/3)
        8,
        9,
        10
    ],
    [ // three (3/3)
        11,
        12,
        13
    ],
    [ // four
        14,
        15,
        16,
        17
    ],
    [ // three (1/3)
        18,
        19,
        20
    ], // and so on..
]

I have tried with this code I have customized:

const arr; // my array of values
const chuncked = arr.reduce((acc, product, i) => {
    if (i % 3) {
        return acc;
    } else if (!didFourWayReduce) {
        didFourWayReduce = true;
        fourWayReduces++;

        if ((fourWayReduces - 1) % 2) { // only make every second a "4 row"
            return [...acc, arr.slice(i, i + 3)];
        } else {
            return [...acc, arr.slice(i, i + 4)];
        }
    } else {
        didFourWayReduce = false;
        return [...acc, arr.slice(i, i + 3)];
    }
}, []);

And it works, almost, expect that the first chunk of threes (1/3) have the last element of the chunk with 4. So 1 key is repeated every first chunk of three. Like so:

[
    [
        1,
        2,
        3,
        4
    ],
    [
        4, // this one is repeated, and it shouldn't be
        5,
        6
    ]
]

Body:
A recursive approach is fairly elegant:

const chunks = (xs, [s, ...ss]) =>
  xs.length ? [xs .slice (0, s), ... chunks (xs .slice (s), [...ss, s])] : []

const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
const sizes = [4, 3, 3, 3]

console .log (chunks (data, sizes))

.as-console-wrapper { max-height: 100% !important; top: 0; }

By replacing [s, ...ss] with [...ss, s], we pass a cycled version of the sizes array, so that for instance, [4, 3, 3, 3] becomes [3, 3, 3, 4].  This makes it easy to parse step-by-step.


问:
ClassNotFoundException when running JUnit test in Maven
I'm currently trying to set up automated testing for a Maven project, but I've run into a problem. When running my tests using mvn test, I get the following result:

```<code>-------------------------------------------------------------------------------
Test set: no.digipat.patornat.servlets.ServletTests
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.398 s <<< FAILURE! - in no.digipat.patornat.servlets.ServletTests
no.digipat.patornat.servlets.ServletTests  Time elapsed: 0.368 s  <<< ERROR!
java.lang.NoClassDefFoundError: com/mongodb/OperationExecutor
Caused by: java.lang.ClassNotFoundException: com.mongodb.OperationExecutor

</code>```

I get the same error when running the tests in Eclipse.

This is my pom.xml:

```<code><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>no.digipat.patornat</groupId>
  <artifactId>backend</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>Pat or Nat Backend</name>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.target>11</maven.compiler.target>
    <maven.compiler.source>11</maven.compiler.source>
  </properties>

  <repositories>
    <repository>
      <id>cytomine-uliege-Cytomine-java-client</id>
      <url>https://packagecloud.io/cytomine-uliege/Cytomine-java-client/maven2</url>
      <releases>
        <enabled>true</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
  </repositories>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.13</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.lordofthejars</groupId>
      <artifactId>nosqlunit-mongodb</artifactId>
      <version>1.0.0</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.github.fakemongo</groupId>
      <artifactId>fongo</artifactId>
      <version>2.2.0-RC2</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.github.stefanbirkner</groupId>
      <artifactId>system-rules</artifactId>
      <version>1.19.0</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>3.0.1</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>be.cytomine.client</groupId>
      <artifactId>cytomine-java-client</artifactId>
      <version>2.0.7-SNAPSHOT</version>
    </dependency>
    <dependency>
      <groupId>org.mongodb</groupId>
      <artifactId>mongo-java-driver</artifactId>
      <version>3.12.1</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.0.0-M4</version>
        <configuration>
          <includes>
            <include>ServletTests.java</include>
          </includes>
        </configuration>
      </plugin>
    </plugins>
  </build>

</project>

</code>```

The relevant Java files:

ServletTests.java:

```<code>package no.digipat.patornat.servlets;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.contrib.java.lang.system.EnvironmentVariables;
import org.junit.rules.RuleChain;
import org.junit.rules.TestRule;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;

import static com.lordofthejars.nosqlunit.mongodb.InMemoryMongoDb.InMemoryMongoRuleBuilder.newInMemoryMongoDbRule;

@RunWith(Suite.class)
@SuiteClasses({MyTest.class})
public class ServletTests {

    private static final EnvironmentVariables environmentVariables = new EnvironmentVariables();
    @ClassRule
    public static final TestRule chain = RuleChain
        .outerRule(newInMemoryMongoDbRule().build())
        .around(environmentVariables);

    @BeforeClass
    public static void setUpClass() {
        environmentVariables.set("MY_VARIABLE", "some value");
    }

}

</code>```

MyTest.java:

```<code>package no.digipat.patornat.servlets;
import static org.junit.Assert.*;

import org.junit.Test;

public class MyTest {

    @Test
    public void test() {
        fail("Not yet implemented");
    }

}

</code>```

Any ideas on how to solve this? I tried running mvn clean (which previously helped me fix a similar issue), but to no avail.

答: It seems that the issue was that the latest versions of Fongo and mongo-java-driver are incompatible. When I change the dependencies of Fongo and/or the Mongo Java driver to older versions (I specifically tried versions 2.1.0 and 3.6.3, respectively), the error disappears. However, since this solution seems rather fragile and inflexible, the best bet is probably to switch to an alternative to Fongo. According to this GitHub comment, mongo-java-server could be a good option. A perhaps more robust alternative, and the one I'll probably end up using, is to use a "real" test database. This article has information about a couple of ways to do this.</p>

Body:
I'm currently trying to set up automated testing for a Maven project, but I've run into a problem. When running my tests using mvn test, I get the following result:

-------------------------------------------------------------------------------
Test set: no.digipat.patornat.servlets.ServletTests
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.398 s <<< FAILURE! - in no.digipat.patornat.servlets.ServletTests
no.digipat.patornat.servlets.ServletTests  Time elapsed: 0.368 s  <<< ERROR!
java.lang.NoClassDefFoundError: com/mongodb/OperationExecutor
Caused by: java.lang.ClassNotFoundException: com.mongodb.OperationExecutor

I get the same error when running the tests in Eclipse.

This is my pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>no.digipat.patornat</groupId>
  <artifactId>backend</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>Pat or Nat Backend</name>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.target>11</maven.compiler.target>
    <maven.compiler.source>11</maven.compiler.source>
  </properties>

  <repositories>
    <repository>
      <id>cytomine-uliege-Cytomine-java-client</id>
      <url>https://packagecloud.io/cytomine-uliege/Cytomine-java-client/maven2</url>
      <releases>
        <enabled>true</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
  </repositories>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.13</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.lordofthejars</groupId>
      <artifactId>nosqlunit-mongodb</artifactId>
      <version>1.0.0</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.github.fakemongo</groupId>
      <artifactId>fongo</artifactId>
      <version>2.2.0-RC2</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.github.stefanbirkner</groupId>
      <artifactId>system-rules</artifactId>
      <version>1.19.0</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>3.0.1</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>be.cytomine.client</groupId>
      <artifactId>cytomine-java-client</artifactId>
      <version>2.0.7-SNAPSHOT</version>
    </dependency>
    <dependency>
      <groupId>org.mongodb</groupId>
      <artifactId>mongo-java-driver</artifactId>
      <version>3.12.1</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.0.0-M4</version>
        <configuration>
          <includes>
            <include>ServletTests.java</include>
          </includes>
        </configuration>
      </plugin>
    </plugins>
  </build>

</project>

The relevant Java files:

ServletTests.java:

package no.digipat.patornat.servlets;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.contrib.java.lang.system.EnvironmentVariables;
import org.junit.rules.RuleChain;
import org.junit.rules.TestRule;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;

import static com.lordofthejars.nosqlunit.mongodb.InMemoryMongoDb.InMemoryMongoRuleBuilder.newInMemoryMongoDbRule;

@RunWith(Suite.class)
@SuiteClasses({MyTest.class})
public class ServletTests {

    private static final EnvironmentVariables environmentVariables = new EnvironmentVariables();
    @ClassRule
    public static final TestRule chain = RuleChain
        .outerRule(newInMemoryMongoDbRule().build())
        .around(environmentVariables);

    @BeforeClass
    public static void setUpClass() {
        environmentVariables.set("MY_VARIABLE", "some value");
    }

}

MyTest.java:

package no.digipat.patornat.servlets;
import static org.junit.Assert.*;

import org.junit.Test;

public class MyTest {

    @Test
    public void test() {
        fail("Not yet implemented");
    }

}

Any ideas on how to solve this? I tried running mvn clean (which previously helped me fix a similar issue), but to no avail.


问:
Not Allowing Multiple Button Presses
I'm building a camera app with Camera2 API, relatively new to Android development. Everything is working just working out the bugs. But I have a switch camera button, going from the front camera to the back or vise-versa. If the user continuosly presses the button, the app will crash. Trying to set it up in a way that it finishes everything it needs to do before the button can be used again.

I have the button set to enabled, but after press, it disables the button until everyting finishes, then renables, but that doesn't seem to work:

```<code>//The button to switch the camera to front and back camera.
    mChangeCamera = (ImageButton) findViewById(R.id.change_camera);
    mChangeCamera.setEnabled(true);
    mChangeCamera.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
        mChangeCamera.setEnabled(false);
            closeCamera();
            //  stopBackgroundthread();
            if (mTextureView.isAvailable()) {
                setUpCamera(mTextureView.getWidth(), mTextureView.getHeight());
                transformImage(mTextureView.getWidth(), mTextureView.getHeight());
                connectCamera();

            } else {
                mTextureView.setSurfaceTextureListener(mSurfaceTextureListener);
            }

            mChangeCamera.setEnabled(true);
        }
    });
</code>```

there has to be a simple way to do this, but not finding anyting from searchs. Anyone know how I can set it up not to crash when the user smashes the button?

答:
Alight, so I ended up figuring out how to do this. You can use a handler with a post delay like so:</p>

```<code> mChangeCamera = (ImageButton) findViewById(R.id.change_camera);
    mChangeCamera.setEnabled(true);
    mChangeCamera.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            mChangeCamera.setEnabled(false);
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    mChangeCamera.setEnabled(true);
                }
            },1000);
            closeCamera();
            //  stopBackgroundthread();
            if (mTextureView.isAvailable()) {
                setUpCamera(mTextureView.getWidth(), mTextureView.getHeight());
                transformImage(mTextureView.getWidth(), mTextureView.getHeight());
                connectCamera();

            } else {
                mTextureView.setSurfaceTextureListener(mSurfaceTextureListener);
            }

        }
    });
</code>```

Title: Not Allowing Multiple Button Presses

Body:
I'm building a camera app with Camera2 API, relatively new to Android development. Everything is working just working out the bugs. But I have a switch camera button, going from the front camera to the back or vise-versa. If the user continuosly presses the button, the app will crash. Trying to set it up in a way that it finishes everything it needs to do before the button can be used again.

I have the button set to enabled, but after press, it disables the button until everyting finishes, then renables, but that doesn't seem to work:

//The button to switch the camera to front and back camera.
    mChangeCamera = (ImageButton) findViewById(R.id.change_camera);
    mChangeCamera.setEnabled(true);
    mChangeCamera.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
        mChangeCamera.setEnabled(false);
            closeCamera();
            //  stopBackgroundthread();
            if (mTextureView.isAvailable()) {
                setUpCamera(mTextureView.getWidth(), mTextureView.getHeight());
                transformImage(mTextureView.getWidth(), mTextureView.getHeight());
                connectCamera();

            } else {
                mTextureView.setSurfaceTextureListener(mSurfaceTextureListener);
            }

            mChangeCamera.setEnabled(true);
        }
    });

there has to be a simple way to do this, but not finding anyting from searchs. Anyone know how I can set it up not to crash when the user smashes the button?

Body:
Alight, so I ended up figuring out how to do this. You can use a handler with a post delay like so:

 mChangeCamera = (ImageButton) findViewById(R.id.change_camera);
    mChangeCamera.setEnabled(true);
    mChangeCamera.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            mChangeCamera.setEnabled(false);
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    mChangeCamera.setEnabled(true);
                }
            },1000);
            closeCamera();
            //  stopBackgroundthread();
            if (mTextureView.isAvailable()) {
                setUpCamera(mTextureView.getWidth(), mTextureView.getHeight());
                transformImage(mTextureView.getWidth(), mTextureView.getHeight());
                connectCamera();

            } else {
                mTextureView.setSurfaceTextureListener(mSurfaceTextureListener);
            }

        }
    });


问:
Run Elasticsearch on AWS EC2 with Docker
I'm trying to run Elasticsearch with Docker on an AWS EC2 instance, but when it runs, after a few seconds will be stopped, any of you have any experiences what the problem could be?

This is my Elasticsearch config in the docker-compose.yaml:

```<code> elasticsearch:
  build:
    context: ./elasticsearch
    args:
      - ELK_VERSION=${ELK_VERSION}
  volumes:
    - elasticsearch:/usr/share/elasticsearch/data
  environment:
    - cluster.name=laradock-cluster
    - node.name=laradock-node
    - bootstrap.memory_lock=true
    - discovery.type=single-node
    - "ES_JAVA_OPTS=-Xms7g -Xmx7g"
    - xpack.security.enabled=false
    - xpack.monitoring.enabled=false
    - xpack.watcher.enabled=false
    - cluster.initial_master_nodes=laradock-node
  ulimits:
    memlock:
      soft: -1
      hard: -1
    nofile:
      soft: 65536
      hard: 65536
  ports:
    - "${ELASTICSEARCH_HOST_HTTP_PORT}:9200"
    - "${ELASTICSEARCH_HOST_TRANSPORT_PORT}:9300"
  depends_on:
    - php-fpm
  networks:
    - frontend
    - backend
</code>```

And This is my Dockerfile:

```<code>FROM docker.elastic.co/elasticsearch/elasticsearch:7.5.1

RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch discovery-ec2

EXPOSE 9200 9300
</code>```

Also, I did sysctl -w vm.max_map_count=655360 on my AWS EC2 instance

Notice: my AWS EC2 instance is Ubuntu 18.4

Thanks

答:
I am not sure about your docker-compose.yaml as you are not referring this in your dockerfile, But I am able to reproduce the issue. I launched same ubuntu 18.4 in my AWS account and used your dockerfile to launch a ES docker container using below commands:

```<code>docker build --tag=elasticsearch-custom .
docker run -ti -v /usr/share/elasticsearch/data elasticsearch-custom
</code>```

And my docker container was also stopping just after starting up as shown below:

```<code>ubuntu@ip-172-31-32-95:~$ docker ps -a
CONTAINER ID        IMAGE                  COMMAND                  CREATED             STATUS                      PORTS               NAMES
03cde4a19389        elasticsearch-custom   "/usr/local/bin/dock…"   33 seconds ago      Exited (78) 6 seconds ago                       mystifying_napier
</code>```

When checked the logs on console, when starting the docker, I found below error:

ERROR: [1] bootstrap checks failed [1]: the default discovery settings
  are unsuitable for production use; at least one of
  [discovery.seed_hosts, discovery.seed_providers,
  cluster.initial_master_nodes] must be configured

Which is very well known error and can be easily resolved just by adding -e "discovery.type=single-node" to docker run command. After adding this in docker run command as below:

docker run -e "discovery.type=single-node" -ti -v /usr/share/elasticsearch/data elasticsearch-custom

its running fine as shown below:

```<code>CONTAINER ID        IMAGE                  COMMAND                  CREATED             STATUS              PORTS                NAMES
191fc3dceb5a        elasticsearch-custom   "/usr/local/bin/dock…"   8 minutes ago       Up 8 minutes        9200/tcp, 9300/tcp   recursing_elgamal
</code>```

Body:
I'm trying to run Elasticsearch with Docker on an AWS EC2 instance, but when it runs, after a few seconds will be stopped, any of you have any experiences what the problem could be?

This is my Elasticsearch config in the docker-compose.yaml:

 elasticsearch:
  build:
    context: ./elasticsearch
    args:
      - ELK_VERSION=${ELK_VERSION}
  volumes:
    - elasticsearch:/usr/share/elasticsearch/data
  environment:
    - cluster.name=laradock-cluster
    - node.name=laradock-node
    - bootstrap.memory_lock=true
    - discovery.type=single-node
    - "ES_JAVA_OPTS=-Xms7g -Xmx7g"
    - xpack.security.enabled=false
    - xpack.monitoring.enabled=false
    - xpack.watcher.enabled=false
    - cluster.initial_master_nodes=laradock-node
  ulimits:
    memlock:
      soft: -1
      hard: -1
    nofile:
      soft: 65536
      hard: 65536
  ports:
    - "${ELASTICSEARCH_HOST_HTTP_PORT}:9200"
    - "${ELASTICSEARCH_HOST_TRANSPORT_PORT}:9300"
  depends_on:
    - php-fpm
  networks:
    - frontend
    - backend

And This is my Dockerfile:

FROM docker.elastic.co/elasticsearch/elasticsearch:7.5.1

RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch discovery-ec2

EXPOSE 9200 9300

Also, I did sysctl -w vm.max_map_count=655360 on my AWS EC2 instance

Notice: my AWS EC2 instance is Ubuntu 18.4

Thanks

Body:
I am not sure about your docker-compose.yaml as you are not referring this in your dockerfile, But I am able to reproduce the issue. I launched same ubuntu 18.4 in my AWS account and used your dockerfile to launch a ES docker container using below commands:

docker build --tag=elasticsearch-custom .
docker run -ti -v /usr/share/elasticsearch/data elasticsearch-custom

And my docker container was also stopping just after starting up as shown below:

ubuntu@ip-172-31-32-95:~$ docker ps -a
CONTAINER ID        IMAGE                  COMMAND                  CREATED             STATUS                      PORTS               NAMES
03cde4a19389        elasticsearch-custom   "/usr/local/bin/dock…"   33 seconds ago      Exited (78) 6 seconds ago                       mystifying_napier

When checked the logs on console, when starting the docker, I found below error:

ERROR: [1] bootstrap checks failed [1]: the default discovery settings
  are unsuitable for production use; at least one of
  [discovery.seed_hosts, discovery.seed_providers,
  cluster.initial_master_nodes] must be configured

Which is very well known error and can be easily resolved just by adding -e "discovery.type=single-node" to docker run command. After adding this in docker run command as below:

docker run -e "discovery.type=single-node" -ti -v /usr/share/elasticsearch/data elasticsearch-custom

its running fine as shown below:

CONTAINER ID        IMAGE                  COMMAND                  CREATED             STATUS              PORTS                NAMES
191fc3dceb5a        elasticsearch-custom   "/usr/local/bin/dock…"   8 minutes ago       Up 8 minutes        9200/tcp, 9300/tcp   recursing_elgamal


问:
Tabulator Multiple Filter in the same Column (show dropbox)
Hi I'm trying to create a headerFilter that allows multiple filter selection in the same column. Something like headerFilter:"select" but showing probably a dropdown to select which values don you want to filter.
I'm think I need to use a headerFilterFunc but I'm not sure how to pass the selected values.
Could anyone help me?

Thanks!

答:
I think you want something like this I posted with my question about <select> and movableColumns ...

https://jsfiddle.net/hsvyc1a8/

```<code>...
</code>```

Body:
I think you want something like this I posted with my question about <select> and movableColumns ...

https://jsfiddle.net/hsvyc1a8/

...


问:
SIGABORT issued when calling Android Java JNI GetDoubleField()
I am getting a SIGABORT when calling GetDoubleField().

I have written a small sample program to show the issue...

MainActivity.java

```<code>package net.directionalsystems.jnitest;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

// Used to load the 'native-lib' library on application startup.
static {
    System.loadLibrary("native-lib");
}

private static final String TAG = "Mainactivity";

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Example of a call to a native method
    TextView tv = findViewById(R.id.sample_text);

    JniComms jc = new JniComms();
    jc.latitude = 10;
    jc.logitude = 20;
    jc.txtLocation = "Hello";

    try {
        tv.setText(stringFromJNI(jc));
    }
    catch (Exception e)
    {

        Log.e(TAG, "onCreate: ", e);
    }
}

/**
 * A native method that is implemented by the 'native-lib' native library,
 * which is packaged with this application.
 */
public native String stringFromJNI(JniComms jc);
</code>```

}

JniComms.java

```<code>package net.directionalsystems.jnitest;

import java.util.ArrayList;

public class JniComms
{
    public double latitude;
    public double logitude;
    public String txtLocation;
    //public ArrayList<BleStatus> bleStatusArray;

}
</code>```

native-lib.cpp

```<code>#include <jni.h>
#include <string>

extern "C" JNIEXPORT jstring JNICALL
Java_net_directionalsystems_jnitest_MainActivity_stringFromJNI(
        JNIEnv *env,
        jobject jo,
        jobject jc)
        {

            jclass jcClass = env->GetObjectClass(jc);
            jfieldID iId = env->GetFieldID(jcClass, "latitude", "D");

            // Executing the next line causes SIGABORT
            jdouble latitude = env->GetDoubleField(jcClass, iId);

            std::string hello = "Hello world";
    return env->NewStringUTF(hello.c_str());
}
</code>```

The build.gradle file follows...

```<code>apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "net.directionalsystems.jnitest"
        minSdkVersion 23
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                cppFlags ""
            }
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        customDebugType {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            debuggable true
        }
    }
    externalNativeBuild {
        cmake {
            path "src/main/cpp/CMakeLists.txt"
            version "3.10.2"
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
</code>```

This has got to be something simple and stupid that I am doing.

I would like to debug into the NDK code but all I get is the jni.h file displayed and cannot step into the JNI code itself. Having that capability may give me an idea of what is wrong.

Many thanks for any help.

Best regards, Jackie

答:
When reading an instance (non-static) field you're supposed to pass the object, not the class.

So replace:

```<code>jdouble latitude = env->GetDoubleField(jcClass, iId);
</code>```

with:

```<code>jdouble latitude = env->GetDoubleField(jc, iId);
</code>```

Body:
I am getting a SIGABORT when calling GetDoubleField().

I have written a small sample program to show the issue...

MainActivity.java

package net.directionalsystems.jnitest;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

// Used to load the 'native-lib' library on application startup.
static {
    System.loadLibrary("native-lib");
}

private static final String TAG = "Mainactivity";

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Example of a call to a native method
    TextView tv = findViewById(R.id.sample_text);

    JniComms jc = new JniComms();
    jc.latitude = 10;
    jc.logitude = 20;
    jc.txtLocation = "Hello";

    try {
        tv.setText(stringFromJNI(jc));
    }
    catch (Exception e)
    {

        Log.e(TAG, "onCreate: ", e);
    }
}

/**
 * A native method that is implemented by the 'native-lib' native library,
 * which is packaged with this application.
 */
public native String stringFromJNI(JniComms jc);

}

JniComms.java

package net.directionalsystems.jnitest;

import java.util.ArrayList;

public class JniComms
{
    public double latitude;
    public double logitude;
    public String txtLocation;
    //public ArrayList<BleStatus> bleStatusArray;

}

native-lib.cpp

#include <jni.h>
#include <string>

extern "C" JNIEXPORT jstring JNICALL
Java_net_directionalsystems_jnitest_MainActivity_stringFromJNI(
        JNIEnv *env,
        jobject jo,
        jobject jc)
        {

            jclass jcClass = env->GetObjectClass(jc);
            jfieldID iId = env->GetFieldID(jcClass, "latitude", "D");

            // Executing the next line causes SIGABORT
            jdouble latitude = env->GetDoubleField(jcClass, iId);

            std::string hello = "Hello world";
    return env->NewStringUTF(hello.c_str());
}

The build.gradle file follows...

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "net.directionalsystems.jnitest"
        minSdkVersion 23
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                cppFlags ""
            }
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        customDebugType {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            debuggable true
        }
    }
    externalNativeBuild {
        cmake {
            path "src/main/cpp/CMakeLists.txt"
            version "3.10.2"
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

This has got to be something simple and stupid that I am doing.

I would like to debug into the NDK code but all I get is the jni.h file displayed and cannot step into the JNI code itself. Having that capability may give me an idea of what is wrong.

Many thanks for any help.

Best regards, Jackie

Body:
When reading an instance (non-static) field you're supposed to pass the object, not the class.

So replace:

jdouble latitude = env->GetDoubleField(jcClass, iId);

with:

jdouble latitude = env->GetDoubleField(jc, iId);


问:
Select text on click in EditorGridPanel (gwt-ext)
I have a gwt-ext EditorGridPanel, by clicking onto a cell, you can edit its value. The cursor is placed at the beginnig of the cell, but I want to select the whole text in this cell if the user clicks on it. Any idea how I can handle this?

I tried some Listeners etc. but none worked for me yet.

答:
Sorry for my english, with Ext-GWT(GXT) it's posible doing this:

```<code>final TextField<String> text = new TextField<String>();
    text.setAllowBlank(false);
    CellEditor textEditor = new CellEditor(text);
    textEditor.addListener(Events.StartEdit, new Listener<EditorEvent>() {
      public void handleEvent(EditorEvent be) {
        text.setSelectOnFocus(true);
      }
    });
    column.setEditor(textEditor);
    configs.add(column);
</code>```

Just find the way in GWT-Ext, I think will something like this.....I hope this help....

ContentLicense: CC BY-SA 2.5

Body:
Sorry for my english, with Ext-GWT(GXT) it's posible doing this:

final TextField<String> text = new TextField<String>();
    text.setAllowBlank(false);
    CellEditor textEditor = new CellEditor(text);
    textEditor.addListener(Events.StartEdit, new Listener<EditorEvent>() {
      public void handleEvent(EditorEvent be) {
        text.setSelectOnFocus(true);
      }
    });
    column.setEditor(textEditor);
    configs.add(column);

Just find the way in GWT-Ext, I think will something like this.....I hope this help....


问:
loop over table to set the background css
My HTML table has some classes and table tag is used

Want to retain the classes as is, but all my table and tr , th or td are using td bgcolor which is an old technique.

I want to loop over the table and find if that bgcolor is defined, use the same color and convert it to a css based background color so i can print it in IE

```<code>function setBackground() {

var table = document.getElementById("table1");

//i found this in a previous stack overflow answer and tried it

for (var i = 0, row; row = table.rows[i]; i++) {

   for (var j = 0, col; col = row.cells[j]; j++) {

  //this is for debugging purposes... I can't even get this to work
   alert(table.rows[i].cells[j]);

   table.rows[i].cells[j].style.background = "orange"; //just an example

    }
 }
}
</code>```

because IE is not able to print the background lines and colors for some reason using the webkit property

答:
as Taplar mentioned in the comment :

Use document.querySelectorAll('td[bgcolor]') to get the td that have bgcolor, loop through them and set the background to that color :

document.querySelectorAll('td[bgcolor]').forEach(e => {
  const bgColor = e.getAttribute('bgcolor');

  e.removeAttribute('bgcolor'); // optional, if you want to remove the attribute

  e.style.background = bgColor;
})```
<pre class="snippet-code-html lang-html prettyprint-override"><code><table id="table1">
  <thead>
    <th>A</th>
    <th>B</th>
    <th>C</th>
  </thead>
  <tbody>
    <tr>
      <td bgcolor="red">1</td>
      <td>2</td>
      <td>3</td>
    </tr>
    <tr>
      <td>4</td>
      <td bgcolor="green">5</td>
      <td>6</td>
    </tr>
    <tr>
      <td>7</td>
      <td>8</td>
      <td bgcolor="blue">9</td>
    </tr>
  </tbody>
</table></code>```

Body:
My HTML table has some classes and table tag is used

Want to retain the classes as is, but all my table and tr , th or td are using td bgcolor which is an old technique.

I want to loop over the table and find if that bgcolor is defined, use the same color and convert it to a css based background color so i can print it in IE

function setBackground() {

var table = document.getElementById("table1");

//i found this in a previous stack overflow answer and tried it

for (var i = 0, row; row = table.rows[i]; i++) {

   for (var j = 0, col; col = row.cells[j]; j++) {

  //this is for debugging purposes... I can't even get this to work
   alert(table.rows[i].cells[j]);

   table.rows[i].cells[j].style.background = "orange"; //just an example

    }
 }
}

because IE is not able to print the background lines and colors for some reason using the webkit property

Body:
as Taplar mentioned in the comment :

Use document.querySelectorAll('td[bgcolor]') to get the td that have bgcolor, loop through them and set the background to that color :

document.querySelectorAll('td[bgcolor]').forEach(e => {
  const bgColor = e.getAttribute('bgcolor');

  e.removeAttribute('bgcolor'); // optional, if you want to remove the attribute

  e.style.background = bgColor;
})

<table id="table1">
  <thead>
    <th>A</th>
    <th>B</th>
    <th>C</th>
  </thead>
  <tbody>
    <tr>
      <td bgcolor="red">1</td>
      <td>2</td>
      <td>3</td>
    </tr>
    <tr>
      <td>4</td>
      <td bgcolor="green">5</td>
      <td>6</td>
    </tr>
    <tr>
      <td>7</td>
      <td>8</td>
      <td bgcolor="blue">9</td>
    </tr>
  </tbody>
</table>


问:
FB login - Firebase.Auth() Error: The supplied auth credential is malformed or has expired
I'm using react-native-fbsdk: 0.8.0, react-native-firebase: ^5.2.2, react-native: ^0.57.4 and Facebook Test User account.

This happened so suddenly.
Once I sign out from firebase and try to log in again with Facebook.

Error: The supplied auth credential is malformed or has expired. [ Remote site 5XX from facebook.com for USER_INFO ].

I had tried AccessToken.refreshCurrentAccessTokenAsync().
But give me Error: Failed to refresh access token.

The Facebook token will expire in 60 days. Checked the token expired date is Apr 29, 2019.
Change the test user account password and re-login again, still the same.

Is there anything I need to do in facebook or firebase setting?

```<code>const result = await LoginManager.logInWithReadPermissions(["public_profile","email"]);

if (result.isCancelled) {
  this.setState({isLoading : false});
  Alert.alert('Error','Login cancelled. Please try again');
} else {
  try{
    await AccessToken.refreshCurrentAccessTokenAsync();
  }catch(err){
    this.setState({isLoading : false});
    console.log('ereee',err);
  }

  const data = await AccessToken.getCurrentAccessToken();
  var credential = firebase.auth.FacebookAuthProvider.credential(data.accessToken);
  console.log(data.accessToken);
  //here I get expired date is 2019 April 29
  console.log(moment(data.expirationTime).toDate());

  firebase.auth().signInWithCredential(credential)
    .then((usercredential)=>{
      if (usercredential){
      }else{
        this.setState({isLoading : false});
      }
    })
    .catch((error) => {
      console.log(error);
    }
}
</code>```

答:
I know that is not a real solution.. but I've added a logout function before the signIn. I had no problems yet.
The problem consists of the same user tried to connect multiple times without a proper logout. </p>

Body:
I'm using react-native-fbsdk: 0.8.0, react-native-firebase: ^5.2.2, react-native: ^0.57.4 and Facebook Test User account.

This happened so suddenly.
Once I sign out from firebase and try to log in again with Facebook.

Error: The supplied auth credential is malformed or has expired. [ Remote site 5XX from facebook.com for USER_INFO ].

I had tried AccessToken.refreshCurrentAccessTokenAsync().
But give me Error: Failed to refresh access token.

The Facebook token will expire in 60 days. Checked the token expired date is Apr 29, 2019.
Change the test user account password and re-login again, still the same.

Is there anything I need to do in facebook or firebase setting?

const result = await LoginManager.logInWithReadPermissions(["public_profile","email"]);

if (result.isCancelled) {
  this.setState({isLoading : false});
  Alert.alert('Error','Login cancelled. Please try again');
} else {
  try{
    await AccessToken.refreshCurrentAccessTokenAsync();
  }catch(err){
    this.setState({isLoading : false});
    console.log('ereee',err);
  }

  const data = await AccessToken.getCurrentAccessToken();
  var credential = firebase.auth.FacebookAuthProvider.credential(data.accessToken);
  console.log(data.accessToken);
  //here I get expired date is 2019 April 29
  console.log(moment(data.expirationTime).toDate());

  firebase.auth().signInWithCredential(credential)
    .then((usercredential)=>{
      if (usercredential){
      }else{
        this.setState({isLoading : false});
      }
    })
    .catch((error) => {
      console.log(error);
    }
}