src/main/java/com/jcabi/github/wire/CarefulWire.java
/**
     * {@inheritDoc}
     * @checkstyle ParameterNumber (6 lines)
     */
@checkstyle ParameterNumber (6 lines)
@checkstyle ParameterNumber ( 6 lines )
@Override
    @NotNull(message = "response can't be NULL")
    public Response send(
        @NotNull(message = "req can't be NULL") final Request req,
        @NotNull(message = "home can't be NULL") final String home,
        @NotNull(message = "method can't be NULL")final String method,
        @NotNull(message = "headers can't be NULL")
        final Collection<Map.Entry<String, String>> headers,
        @NotNull(message = "content can't be NULL")
        final InputStream content
    ) throws IOException {
        final Response resp = this.origin
            .send(req, home, method, headers, content);
        final int remaining = Integer.parseInt(
            resp.headers().get("X-RateLimit-Remaining").get(0)
        );
        if (remaining < this.threshold) {
            final long reset = Long.parseLong(
                resp.headers().get("X-RateLimit-Reset").get(0)
            );
            final long now = TimeUnit.MILLISECONDS
                .toSeconds(System.currentTimeMillis());
            if (reset > now) {
                final long length = reset - now;
                Logger.info(
                    this,
                    "Remaining number of requests per hour is less than %d. Waiting for %d seconds.",
                    this.threshold, length
                );
                try {
                    TimeUnit.SECONDS.sleep(length);
                } catch (final InterruptedException ex) {
                    Thread.currentThread().interrupt();
                    throw new IllegalStateException(ex);
                }
            }
        }
        return resp;
    }
@ Override @ NotNull ( message = "response can't be NULL" ) public Response send ( @ NotNull ( message = "req can't be NULL" ) final Request req , @ NotNull ( message = "home can't be NULL" ) final String home , @ NotNull ( message = "method can't be NULL" ) final String method , @ NotNull ( message = "headers can't be NULL" ) final Collection < Map . Entry < String , String > > headers , @ NotNull ( message = "content can't be NULL" ) final InputStream content ) throws IOException { final Response resp = this . origin . send ( req , home , method , headers , content ) ; final int remaining = Integer . parseInt ( resp . headers ( ) . get ( "X-RateLimit-Remaining" ) . get ( 0 ) ) ; if ( remaining < this . threshold ) { final long reset = Long . parseLong ( resp . headers ( ) . get ( "X-RateLimit-Reset" ) . get ( 0 ) ) ; final long now = TimeUnit . MILLISECONDS . toSeconds ( System . currentTimeMillis ( ) ) ; if ( reset > now ) { final long length = reset - now ; Logger . info ( this , "Remaining number of requests per hour is less than %d. Waiting for %d seconds." , this . threshold , length ) ; try { TimeUnit . SECONDS . sleep ( length ) ; } catch ( final InterruptedException ex ) { Thread . currentThread ( ) . interrupt ( ) ; throw new IllegalStateException ( ex ) ; } } } return resp ; }
{@inheritDoc}
 @checkstyle ParameterNumber (6 lines)
{ @inheritDoc } @checkstyle ParameterNumber ( 6 lines )
// @checkstyle LineLength (1 line)