java – Optional int parameter ‘id’ is present but cannot be translated into a null value due to being declared as a primitive type

me encuentro con un error que no sé por donde cogerlo. Estoy realizando un api/rest de android studio (RetroFit) con SpringBoot (como servidor).
Resulta que me encuentro con este error:

 Optional int parameter 'id' is present but cannot be translated into a null value due to being declared as a primitive type. Consider declaring it as object wrapper for the corresponding primitive type.

Expongo retrofit interface:

 @PUT("editPlayer{id}")
    Call<PlayerDto> editPlayer(@Body PlayerDto player, @Path("id") int id);

Expongo llamada al servidor:

Settings.RESPONSE_CLIENT.getService()
.editPlayer(editedPlayer, 53)
.enqueue(new Callback<PlayerDto>() {
   @Override
   public void onResponse(Call<PlayerDto> call, Response<PlayerDto> response) {
      editedPlayer = response.body();
      typeError = 0;
   }

   @Override
   public void onFailure(Call<PlayerDto> call, Throwable t) {
      Log.e("Error: ", t.getMessage());
      typeError = 2;
   }
});

Expongo servidor Controller:

@PutMapping("/editPlayer{id}")
    public Player editPlayer(@RequestBody Player player, @Param("id") int id) {
        return service.editPlayer(player.getUsername(), id);
    }

Expongo servidor PlayerService:

public Player editPlayer(String username, int id) {

        repoPlayer.editUserNamePlayer(username, id);
        Optional<Player> player = repoPlayer.findById(id);

        return player.get();
    }

Expongo IPlayerRepository, aunque solo es la “Query” :

@Modifying
    @Query("UPDATE Player p SET p.username= :username WHERE p.id= :id")
    public void editUserNamePlayer(@Param("username")String username, @Param("id") Integer id);

Realizo pruebas con Insomnia y no tengo ningún problema adjunto imagen:
imagen de captura test insomnia put api/rest

Pero no tengo manera de enviar la id desde android studio, parece que se le envia “null”.
Ni ingresandolo a mano ni recogiendolo por parámetro.

Necesito ayuda, muchas gracias de antemano.

java – Id e Produto ficando null quando salvo dados Many To One

Sempre que eu tenho criar uma Lista de itemPedido e usar ele em uma mapper para request, ela acaba como id e produto null. Já trackei com o debugger e ele não pega a referência com o idProduto que eu coloco no Postman. Sou novo nisso então certo q estou deixando passar algo.

O processo seria: Criar um Pedido, que possui uma lista de itemPedido com os atributos Produto e quantidade. Mas o Produto fica como null.

Classe Pedido:

”’
@Entity
@AllArgsConstructor
@NoArgsConstructor
public class Pedido {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Valid
@ManyToOne
@JoinColumn(name = "id_usuario_solicitante")
private Usuario solicitante;

@Valid
@ManyToOne
@JoinColumn(name = "id_endereco")
private Endereco enderecoEntrega;

@Valid
@ManyToOne
@JoinColumn(name = "id_estabelecimento", nullable = false)
private Estabelecimento estabelecimento;

@Valid
@OneToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
@JoinColumn(name = "id_pedido")
private List<ItemPedido> itensPedido;

@Valid
@Enumerated(EnumType.STRING)
private FormaPagamento formaPagamento;

@Enumerated(EnumType.STRING)
private StatusPedido status;

@JsonFormat(pattern = "dd/MM/yyyy HH:mm:ss")
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
private LocalDateTime horarioSolicitacao;

@JsonFormat(pattern = "dd/MM/yyyy HH:mm:ss")
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
private LocalDateTime horarioSaiuParaEntrega;

@JsonFormat(pattern = "dd/MM/yyyy HH:mm:ss")
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
private LocalDateTime horarioEntrega;

@JsonFormat(pattern = "dd/MM/yyyy HH:mm:ss")
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
private LocalDateTime horarioCancelamento;

private BigDecimal valorTotal;

@Valid
@ManyToOne
@JoinColumn(name = "id_entregador")
private Entregador entregador;

public Long getId() {
    return id;
}

public void setId(Long id) {
    this.id = id;
}

public Usuario getSolicitante() {
    return solicitante;
}

public void setSolicitante(Usuario solicitante) {
    this.solicitante = solicitante;
}

public Endereco getEnderecoEntrega() {
    return enderecoEntrega;
}

public void setEnderecoEntrega(Endereco enderecoEntrega) {
    this.enderecoEntrega = enderecoEntrega;
}

public Estabelecimento getEstabelecimento() {
    return estabelecimento;
}

public void setEstabelecimento(Estabelecimento estabelecimento) {
    this.estabelecimento = estabelecimento;
}

public List<ItemPedido> getItensPedido() {
    return itensPedido;
}

public void setItensPedido(List<ItemPedido> itensPedido) {
    this.itensPedido = itensPedido;
}

public FormaPagamento getFormaPagamento() {
    return formaPagamento;
}

public void setFormaPagamento(FormaPagamento formaPagamento) {
    this.formaPagamento = formaPagamento;
}

public StatusPedido getStatus() {
    return status;
}

public void setStatus(StatusPedido status) {
    this.status = status;
}

public LocalDateTime getHorarioSolicitacao() {
    return horarioSolicitacao;
}

public void setHorarioSolicitacao(LocalDateTime horarioSolicitacao) {
    this.horarioSolicitacao = horarioSolicitacao;
}

public LocalDateTime getHorarioSaiuParaEntrega() {
    return horarioSaiuParaEntrega;
}

public void setHorarioSaiuParaEntrega(LocalDateTime horarioSaiuParaEntrega) {
    this.horarioSaiuParaEntrega = horarioSaiuParaEntrega;
}

public LocalDateTime getHorarioEntrega() {
    return horarioEntrega;
}

public void setHorarioEntrega(LocalDateTime horarioEntrega) {
    this.horarioEntrega = horarioEntrega;
}

public LocalDateTime getHorarioCancelamento() {
    return horarioCancelamento;
}

public void setHorarioCancelamento(LocalDateTime horarioCancelamento) {
    this.horarioCancelamento = horarioCancelamento;
}

public BigDecimal getValorTotal() {
    return valorTotal;
}

public void setValorTotal(BigDecimal valorTotal) {
    this.valorTotal = valorTotal;
}

public Entregador getEntregador() {
    return entregador;
}

public void setEntregador(Entregador entregador) {
    this.entregador = entregador;
}

}”’

Classe ItemPedido:

”’@Entity
public class ItemPedido {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne
@JoinColumn(name = "id_produto")
private Produto produto;

private Integer quantidade;

public Long getId() {
    return id;
}

public void setId(Long id) {
    this.id = id;
}

public Produto getProduto() {
    return produto;
}

public void setProduto(Produto produto) {
    this.produto = produto;
}

public Integer getQuantidade() {
    return quantidade;
}

public void setQuantidade(Integer quantidade) {
    this.quantidade = quantidade;
}

}
”’

Classe CriarPedidoRequest:

”’
@Getter
@Setter
@AllArgsConstructor
public class CriarPedidoRequest {

private Long idPedido;
private Long idEstabelecimento;
private Long idUsuarioSolicitante;
private Long idEnderecoEntrega;
private List<ItemPedido> itens;
private FormaPagamento formaPagamento;
private StatusPedido status;
private LocalDateTime horarioSolicitacao;
private LocalDateTime horarioSaiuParaEntrega;
private LocalDateTime horarioEntrega;
private LocalDateTime horarioCancelamento;
private BigDecimal valorTotal;
private Long idEntregador;
private Long idProduto;
private Integer quantidade;

}”’

Classe CriarPedidoService:

”’
@Service
public class CriarPedidoService {

@Autowired
private PedidoRepository pedidoRepository;

@Autowired
private CriarPedidoMapper criarPedidoMapper;

@Autowired
private ProdutoRepository produtoRepository;

@Autowired
private ItemPedidoRepository itemPedidoRepository;

public Pedido salvarPedido(CriarPedidoRequest request) {

    Pedido pedido = criarPedidoMapper.mapear(request);
    pedido.setStatus(StatusPedido.EM_PREPARO);
    pedido.setHorarioSolicitacao(LocalDateTime.now());

    Produto produto = produtoRepository.findById(request.getIdProduto()).get();

    List<ItemPedido> itens = new ArrayList<>();
    ItemPedido itemPedido = new ItemPedido();

    itemPedido.setProduto(produto);
    itemPedido.setQuantidade(request.getQuantidade());
    itens.add(itemPedido);

    pedido.setItensPedido(itens);

    return pedidoRepository.save(pedido);
}

}”’

CriarPedidoMapper:

”’
@Component
public class CriarPedidoMapper {

@Autowired
private UsuarioRepository usuarioRepository;

@Autowired
private EnderecoRepository enderecoRepository;

@Autowired
private EstabelecimentoRepository estabelecimentoRepository;

@Autowired
private EntregadorRepository entregadorRepository;

@Autowired
private ProdutoRepository produtoRepository;

@Autowired
private ItemPedidoRepository itemPedidoRepository;


public Pedido mapear(CriarPedidoRequest request) {

    Usuario usuario = usuarioRepository
            .findById(request.getIdUsuarioSolicitante()).get();

    Endereco enderecoEntrega = enderecoRepository
            .findById(request.getIdEnderecoEntrega()).get();

    Estabelecimento estabelecimento = estabelecimentoRepository
            .findById(request.getIdEstabelecimento()).get();

    Entregador entregador = entregadorRepository
            .findById(request.getIdEntregador()).get();

    Produto produto = produtoRepository
            .findById(request.getIdProduto()).get();

    BigDecimal valor = produto.getValor();
    Integer quantidade = request.getQuantidade();
    BigDecimal valorTotal = BigDecimal.valueOf(quantidade).multiply(valor);



    return new Pedido(request.getIdPedido(), usuario, enderecoEntrega, estabelecimento, request.getItens(),
            request.getFormaPagamento(), request.getStatus(), request.getHorarioSolicitacao(),
            request.getHorarioSaiuParaEntrega(), request.getHorarioEntrega(),
            request.getHorarioCancelamento(), valorTotal, entregador);
}

}
”’

Json:

”’
{
“idEstabelecimento”: 1,
“idUsuarioSolicitante”: 1,
“idEnderecoEntrega”: 1,
“formaPagamento”: “PIX”,
“itens”: (
{
“idProduto”: 1,
“quantidade”: 1
},
{
“idProduto”: 2,
“quantidade”: 2
}
)
}
”’

statistics – Whether to reject the null hypothesis or not at different significant levels.

If you reject a null hypothesis at the 10% level of significance, then explain which of the following statement is correct:

(a) You certainly would reject Ho at 5%.

(b) You are absolutely certain that you would not reject it at 5%.

(c) You would definitely reject Ho at 15% significance level.

(d) You do not have enough information to decide whether you should reject at 15% or not.

I think it’s (c) as p-value < 0.10 (according to the original claim) so it must be less than 0.15. In case of the options above (c) I think it’s not possible to decide as p-value might/might not be smaller than 0.05 as well. I am not sure if I am reasoning this out right or if there are even better reasons for making definite choices.

skiasharp – SKBitmap.Decode is returning NULL for some image files

Can somebody help here.

I am using SkiaSharp 1.68.3 version in .Net Core 3.1 framework.
My requirement is to read the image file (raw file having >3 MB of size with various types like bmp, jpeg, jpg, tiff, png, gift etc) and need to resize with white background color etc and upload into blob storage.

The problem is when I use SKBitmap.Decode( ) method by passing the stream object of the image file, I am getting NULL occasionally. Here is the code, I am using and I don’t understand where am I doing any mistake.

            try
            {
                if (stream == null)
                {
                    return (null, ImageErrorType.ImageFormatError, "Invalid Stream");
                }
                stream.Seek(0, SeekOrigin.Begin);                
                var data = new BinaryReader(stream).ReadBytes((int)stream.Length);
                var imgInfo = SKBitmap.DecodeBounds(data);                
                if (imgInfo.IsEmpty)
                {
                    return (null, ImageErrorType.ImageFormatError, "Invalid Stream");
                }
                var bmp = SKBitmap.Decode(data, imgInfo);
                return (bmp, ImageErrorType.NoError, string.Empty);
            }
            catch (Exception ex)
            {
                return (null, ImageErrorType.UnknownError, ex.Message);
            }
            finally
            {
                stream?.Seek(0, SeekOrigin.Begin);
            }

Here are the two images which is working and not working.

Not Working Image

Working Image

8 – JSON:API error unprocessable entity status 422 entity_id this value should not be null

I’m trying to post a flag with JSON:API but I’m getting the following error:

"errors": [
    {
        "title": "Unprocessable Entity",
        "status": "422",
        "detail": "entity_id: This value should not be null.",
        "source": {
            "pointer": "/data/attributes/entity_id"
        }
    }

I’m very confused because in the data I’m posting, the entity_id is definitely included…

magento2.3 – Magento 2.3.3 + elasticsearch 6 – empty catalog. Elasticsearch adds WHERE (NULL) to product collection

I have elasticsearch 6.8 and M2.3.3.
On the both category and search pages Magento display:

We can't find products matching the selection.

(MYSQL engine works correctly)

Reindex and cache are refreshed. I also added 2 patches:
https://github.com/magento/magento2/issues/27112#issuecomment-748916677

https://devdocs.magento.com/guides/v2.3/release-notes/release-notes-2-3-3-open-source.html#apply-the-catalog-pagination-issue-on-elasticsearch-6x-patch-to-resolve-a-critical-search-result-pagination-issue

Elasticseach is configured properly:

curl -X GET http://elasticsearch:9200/test_product_1_v15/_search?q=sergei

{"took":7,"timed_out":false,"_shards":{"total":5,"successful":5,"skipped":0,"failed":0},"hits":{"total":1,"max_score":4.255225,"hits":({"_index":"test_product_1_v15","_type":"document","_id":"246","_score":4.255225,"_source":{"store_id":"1","sku":"Sergey","status":"1","status_value":"Enabled","visibility":"4","name":"Sergey","category_ids":(2,52,84,125),"position_category_2":"0","name_category_2":"Test Category","position_category_52":"0","name_category_52":"Test Category 2","position_category_84":"0","name_category_84":"Test Category 3","position_category_125":"0","name_category_125":"Test","price_4_1":"80.000000","price_0_1":"100.000000","price_1_1":"100.000000","price_2_1":"100.000000","price_3_1":"100.000000","price_5_1":"100.000000","price_6_1":"100.000000"}})}}

Here is the final SQL query from list.phtml – it contains strange condition WHERE (NULL)

SELECT `e`.*, `price_index`.`price`, `price_index`.`tax_class_id`, `price_index`.`final_price`, IF(price_index.tier_price IS NOT NULL, LEAST(price_index.min_price, price_index.tier_price), price_index.min_price) AS `minimal_price`, `price_index`.`min_price`, `price_index`.`max_price`, `price_index`.`tier_price`, IFNULL(review_summary.reviews_count, 0) AS `reviews_count`, IFNULL(review_summary.rating_summary, 0) AS `rating_summary` FROM `catalog_product_entity` AS `e`
 INNER JOIN `catalog_product_index_price` AS `price_index` ON price_index.entity_id = e.entity_id AND price_index.website_id = '1' AND price_index.customer_group_id = 0
 LEFT JOIN `review_entity_summary` AS `review_summary` ON e.entity_id = review_summary.entity_pk_value AND review_summary.store_id = 1 AND review_summary.entity_type = (SELECT `review_entity`.`entity_id` FROM `review_entity` WHERE (entity_code = 'product')) WHERE (NULL)

Without this condition all seems fine.

I logged collection in this method (I suppose it’s elasticsearch output(?)): MagentoElasticsearchModelLayerCategoryItemCollectionProvider::getCollection()

and WHERE (NULL) already here:

SELECT `e`.* FROM `catalog_product_entity` AS `e` WHERE (NULL)

Any ideas why elastic search adds this condition and how can I rightly discard it?

If elastic search (magento extension) adds NULL because the answer from elastic search is empty, how can I debug it in magento?

que hacer cuando un update te devuelve NULL en php?

Estoy haciendo un Crud con poo y mvc. Tengo problemas al hacer el update, me retorna un NULL.

$objEmpleado = new empleadoo($id2, $nombre, $telefono, $cargo, $email );

$objControlempleados = new controlempleados($objEmpleado);
$r = $objControlempleados->modificar();

var_dump($r);

la anterior es la clase donde recibo los datos y los envió al control.

function modificar()
{ $cod=$this->objEmpleados->getId();

       `` $nom=$this->objEmpleados->getNombre();``

        $tel=$this->objEmpleados->getTelefono();
        $car=$this->objEmpleados->getCargo();
        $ema=$this->objEmpleados->getEmail();
        $objControlConexion = new ControlConexion();
        $objControlConexion->abrirBd("localhost","root","","bdmesaayuda");
        $comandoSql = "UPDATE empleados SET nombre = '".$nom."', telefono = '".$tel."', cargo = '".$car."', email = ".$ema." where id_Empleado = '".$cod."'";
        $objControlConexion->ejecutarComandoSql($comandoSql);
        $objControlConexion->cerrarBd();
    }
    ``

y esta es el códido del control donde esta la sentencia SQL.

kubernetes – Zookeeper-shell is Returning null for broker requests

Background

On my Kubernetes cluster, I have installed Zookeeper & Kafka using Confluent Operator. I have confirmed that they are configured properly by creating and publishing to a Kafka topic.

Problem

When I use the zookeeper-shell, the command:
get /brokers/ids returns null, while I’m expecting something like (0, 1, 2)

Details

I am using the zookeeper-shell from within the Kubernetes cluster, and am connecting without difficulty with the following command:
~/bin/zookeeper-shell zookeeper:2181

The following commands output the correct (non-null) response: get /zookeeper/config, get /cluster/id

But the following commands return null: get /brokers/ids, get /brokers/topics

More Info

The fact that I know the brokers are working makes this strange. It could be a security issue, but it seems strange that the other requests would work in that case. Finally, Confluent Control Center is directly telling me that broker.id 1 is the controller, which implies that this data is somehow retrievable. Any help here would be appreciated. Thank you.

android – Erro com tipo personalizado retornando null

Tenho que pegar uma imagem da minha API atraves de um objeto personalizado(PokemonItem) mas esta dando um erro que me retorna somente null no meu PokemonImage. Alguem pode me ajudar? Ja tentei usar conversores mas nao deu certo

Log:

private final com.example.pokedex.model.PokemonImage images = null;
                                                     ^
FAILURE: Build failed with an exception.

* What went wrong:
    Execution failed for task ':app:kaptDebugKotlin'.
    > A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
       > java.lang.reflect.InvocationTargetException (no error message)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more 
log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.5/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 2s

PokemonItem.java (para onde sou direcionado ao clicar no erro)

private final com.example.pokedex.model.PokemonImage images = null;
@org.jetbrains.annotations.NotNull()

classe PokemonItem

import androidx.room.Entity
import androidx.room.PrimaryKey
import androidx.room.TypeConverters
import com.example.pokedex.Converters
import com.google.gson.annotations.SerializedName
import java.io.Serializable

@Entity(tableName = "PokemonItem")
@TypeConverters(Converters::class)
data class PokemonItem(
    @PrimaryKey(autoGenerate = false)
    var id: String = "",
    @SerializedName("name") val nome: String = "",
    val images: PokemonImage,
    val types: List<String>,
    val abilities: List<PokemonAbility>,
    val hp: String = ""

) : Serializable

data class PokemonImage

data class PokemonImage(
@SerializedName("small") val smallImageUrl: String
)